Something that has been nagging at me is that I've known I want to introduce $WORD, $(GR O UP), $TU.P.LE etc. (tentative names VAR-WORD!, VAR-GROUP!, VAR-TUPLE!).
At first glance it seems like it would be a loss if $XXX didn't in the baseline evaluator evaluate to looking up environment variables.
But this would be a different behavior for an ANY-WORD!...which up until now, the type of word has not mattered. Would it spread to SET?
>> set-env "SOMETHING" "TRUE"
>> SOMETHING: 10
>> set (in [] '$SOMETHING) "FALSE"
== "FALSE"
>> SOMETHING
== 10
>> get-env "SOMETHING"
== "FALSE"
Hmmm. Lots of issues there...including that Unix environment variables are case-sensitive, Windows ones are not.
The implementation mechanism of this would presumably have to introduce some sort of "pseudo-object" named environment
/env
, and then the "specifier" would have to say (in a similar way to which the ".WORD" lookups would say to look in a "current object") that the $ words should look up in env. (See related discussion about "Binding Indirection")
Simpler Thought...
A simpler thought (that doesn't rock the boat for one feature) would be that this is a bridge too far for an ANY-WORD!, and they should look up just like any other word, and it's only weird shell dialects that would think that a $WORD meant environment variables.
But then the question might be what the $ buys you.
Maybe I was too hasty in saying that the @ was the right thing to sacrifice for "get variable with binding", and $ should have done that?
>> $word
== word ; bound
>> @word
== @word ; bound?
(A line of argumentation that @word
should be bound, is that if you want an unbound one you can get it by quoting with '@word
, but then again if the @ operator does not bind e.g. @ foo... but $ does, e.g. $ foo. So maybe not affecting the binding is the better choice.)
This would let us put back the @ for "as-is" variable usage in parse. And it would make more sense for a thing named VAR-WORD! (bound variable in evaluator, environment var in shell dialect...)
Urrrgh. I hate that it seems like that's probably right. :-/ (Thankfully, git lets us audit/reverse such decisions...assuming you're diligent about not changing too many unrelated things in one commit, which I thankfully was careful about with the @ change.)
Loss of $ For Weird Idea I Had
If the $ operator were used for binding that would be a bit sad, as I'd kind of hoped that could be a variadic function that could run the shell dialect:
extension: "txt"
$ ls -alF *.(extension)
But, maybe that's a bad way to package it in the box, and specialty scripts that don't care about a $ operator for binding purposes can override it, encouraging the more traditional:
extension: "txt"
shell [ls -alF *.(extension), echo $SOMETHING]