-
Notifications
You must be signed in to change notification settings - Fork 2
path_expansion
This is just working and I haven't given it much thought yet. I don't know if this is good or bad. or if I shouldn't just make an entire macro system after lisp.
I created this, because, I think, in the process of adding variable bindings I broke the old fashioned do-list. But I don't remember. It's been a tough summer with the concussion and cataractes and all.
Either way, here it is. ~ causes the thing after to be expanded to it's value if it can be resolved.
If the thing starts with:
- / it's taken to be an absolute path in the datastore.
- . it's taken to be a value in the current with.
- Otherwise it's taken to be a value in the current with stack.
A back ` protects something from being expanded once. This allows for the function being defined to be a reference to be expanded at execution time, instead of being expanded at definition time.
without the ` the function could still work but would be the equivalent of a hard coded value. Strings are weird here.
At any rate, here's an example session. It's the default with stack of /home with msg in it. So msg can be found three ways from the standpoint of expansion..
- ~/home/msg - goes directly to there
- ~.msg - looks for it in the top with, (/home).
- ~msg - looks for it in the entire with-stack.
Another affect of '.' is with pop. When popping results which are maps if popping to '.' the map will be merged into the current with.
msg
SPR:> with-stack /home /
SPR:> show /home msg: hello, welcome home.
SPR:> def foo "myfoo" log/info `~.msg
SPR:> help foo
"myfoo" Type: dolist Source: [log/info ~.msg]
SPR:> def foo "myfoo" log/info `~msg
SPR:> help foo
"myfoo" Type: dolist Source: [log/info ~msg]
SPR:> foo hello, welcome home.
SPR:> def foo "myfoo" log/info `~.msg
SPR:> foo hello, welcome home.
SPR:> def foo "myfoo" log/info `~/home/msg
SPR:> foo hello, welcome home.
SPR:> show /home msg: hello, welcome home.
SPR:> def foo "myfoo" log/info `~/home/msg
SPR:> foo hello, welcome home.
SPR:> help foo
"myfoo" Type: dolist Source: [log/info ~/home/msg]
SPR:> def foo "myfoo" log/info `~.msg
SPR:> help foo
"myfoo" Type: dolist Source: [log/info ~.msg]
SPR:> foo hello, welcome home.
SPR:> def foo "myfoo" log/info `~msg
SPR:> foo hello, welcome home.