-
Notifications
You must be signed in to change notification settings - Fork 2
how
I imagine them to be a series of steps that try to do something according to some criteria. These steps will accrue and store data each step possibly impacting the next. At some point this process will accomplish it's task or it will fail. Perhaps it is approximately infinite.
In any case we might want to iterate that process, or run it once in a while, or use it iteractively. And probably with different criteria as well.
So, there is configuration. SPR builds it automatically from it's modules. The last thing, is to load your configuration. A configuration file is what can make SPR an application. SPR builds the config in memory, as well as the rest of the datastore. Both are constructed from the modules/namespaces as they are created.
You can save the full config to your local directory with save_config.
You can wander around anywhere you want and look at things with ls and show. Data can be copied. There are stacks to push and pop, results to move.
You can create a custom stack of scopes from any location in the datastore.
So we set up the /config tree. We point at the bits we want by building
a with stack and we top it off with a work space.
The particle module uses /device.
with /config/timeout
with /config/dialogs
with /device
Then we can just worry about where our data is, and tell our functions to do things.
In the case of the particle io processes, it all stays right there in /device each step adds or uses a little more data.
Using with to move around and create a stack of data scopes, any python function can be called and it's parameters will be filled in automatically. Or you can give some or all of them yourself.
So there's that. SPR fails very nicely. Sometimes too nicely during development. It logs everything, and you can add more.
SPR> help log
Yaml code. It's a standalone, so if your Yaml gets big, or you just like it being separate from your .spr code, then put it here instead.
SPR code. This can be loaded well, and if all you need is to import and use some python functions it may be all that is needed.
Python code. If you need/want to wrap something up do it with a .py file, import what you want there, write a little code. Then create your namespace in your spr code by importing your python code.
If SPR already has the functionality you need, it is possible, that all you need to create a process is a configuration file. Or Maybe an spr file, and possibly a bit of python code. The amount of python code seems to be disappearing.
The basic gist is that config (yaml) files are loaded into a dataspace. Each spr extension adds to that config and space as needed by defining some yaml. Each spr extension can also define spr and python functions which go into namespaces. And which can then be used to create processes.
Each spr extension may also add work datastructures outside of /config in the datastore.
The with stack is used to manage the variable scoping for function argument resolution. This is not neceassary to use but it simplifies everything to do so.
An application is really just another spr extension. It can have yaml python and spr code. Once there is functionality you want, then setting the autoexec in SPR-config.yaml will cause SPR to do that thing by default.
with /config/timeout
with /config/dialogs
with /user
Really, there's not very much, and it'll explain a lot.
Examining the .spr, .py and .yaml files for any given extension will help to explain a lot. As will reading as much of this wiki as possible.
I am not sure, but I think, just running the REPL SPR -r and exploring the datastore,
the namespaces, and reading the help, and trying to do things is a great place to start.
When starting a new idea, it comes down to basic programming.
- define the data you need to adhere to - write some YAML.
- define the data you need to accumulate - write some YAML.
- define each step you need in order to fill and transform and do something with your data
When the SPR extensions exist, it is an easy matter of defining some yaml defaults, defining some SPR symbols and chaining them together.
That will make a simple python project for you with everything you need, just fill in the blanks.
More information is available on extensions in the wiki.
An extension can be run as an application or just used as a library. That just depends on the configuration that is used.