Open tomekpiotrowski opened 8 years ago
Would it be possible to handle implicit destructuring? Having to call cursor:key
and cursor:value
doesn't seem to add much benefit compared to simply iterating on lex:keys
.
But if we could have for key, value in lex { }
, that'd be huge.
for
argslist in
expression
Would be a parser and compiler change. It's definitely doable though. What it requires though, to be a properly generic language construct and not just hardcoded to work only with lexicon
, is a means for a Structure
like lexicon to specify "these are my suffixes to use by default in an arglist context" (and who knows, maybe even a way for the user to change that in a script with syntax something like:
for n, bod, ap in myListOfVessels suffixes "name", "body", "apoapsis" { }
)
And then that might even open up constructs like :
set n, bod, ap to myListOfVessels suffixes "name", "body", "apopasis".
or
myFunc:call( myListOfVessels suffixes "name", "body", "apoapsis" ).
We could introduce a new structure -
ENTRY
(that would have 2 suffixes:KEY
andVALUE
) and makeLexicon
enumerable with every iteration returning an instance ofENTRY
.