-
Notifications
You must be signed in to change notification settings - Fork 2
symbols
- namespaces.
- lists of symbols, _dolist_s.
- python functions, _fptr_s.
- lists of symbols, but which resolve to partially completed fptr commands, these are called _partial_s.
dolist commands are commands defined in spr or the configuration.
They are strings which can be parsed and evaluated by the REPL/interpreter.
They are created with the def command.
dolist commands can be built from other dolist commands and fptr commands. dolist commands can be defined in yaml, in python code, or interactively in the REPL.
This was how it was, still is, so if you had two things you wanted to do, they both needed to be defined in order to make them into something bigger.
Where before it was necessary to create symbols for everything, now they can be listed. Now, it is possible to also define a list of commands using YAML syntax for a list. Which at the REPL looks like this.
SPR:> def foo "my foo" - cli/msg "hello" - cli/msg "goodbye"
But when coded could look like this.
def foo "Say hello and goodbye with prompts"
- cli/msg "hello"
- cli/msg "goodbye"
Now this;
def hello "my hello" cli/msg "hello"
def goodbye "my goodbye" cli/msg "goodbye"
def foo "Say hello and goodbye with prompts"
hello goodbye
Turns into this:
def foo "Say hello and goodbye with prompts"
- cli/msg "hello"
- cli/msg "goodbye"
And our name space will be less cluttered.
After being defined, help looks like this.
SPR:> help foo
SPR Help
=============================================
foo
--------------
"Say hello and goodbye with prompts"
Type: dolist
Source:
- cli/msg "hello"
- cli/msg "goodbye"
And execution is this;
SPR:> foo
"hello"
Press any key to continue;
"goodbye"
Press any key to continue;
_fptr_s can only be created with the repl's import and namespace commands through the process of importing a python library into SPR.
_path_s can be created with def-path. They resolve before execution/function calls to their value. They can also be used as a shortcut to a destination.
_partial_s are created with the partial command.
Note: They do not currently use pythons func.partial(),
they work in simpler SPR sort of way.
partial commands are built from fptr commands. partial commands are like dolist commands. Except that the first symbol in the list is an fptr symbol, and the list is not everything the fptr function needs. when using a partial, they act just like fptr functions, you just have to leave off some or all of the first arguments. A partial acts like an alias for a function if no arguments are given. This is how SPR creates show, which is really as/show.
partial commands can only be defined in SPR code, and interactively.