Closed gallais closed 4 years ago
I'm in favour of adding at least a non-recursive let to the language.
It's worth considering first class environments...
Sicko that I am, I kind of want to write explicit environments with a surface syntax uncannily like js objects. E.g.,
{x:5, y:['a 'b 'c]}
which is sugar for
[['x|5] ['y|['a 'b 'c]]]
Syntactically, environments are invoked by application syntax, just like all the other forms of contextualisation. So
{x:5}(x+x)
should yield 10.
Further bikesheddery about whether these things should be comma-separated (they could be space-separated) and whether we might choose =
, not :
(anything but ->
) is welcome.
One should also note that {}
currently means the function which evaluates its arguments, then throws a match exception. I'd suggest that {}
is more useful as the empty environment.
But perhaps "explicit environments" should be its own issue.
As you might imagine, I have played this game before...in the 1990s...in my peculiar dialect of Logo.
At the moment we dump the
LocalEnv' a
and print the raw clauses. This is of course buggy, cf.anonymous.gold
where the result of evaluating:is printed as
instead of
We can:
either print an explicit substitution (adding let-bindings to the language would even allow us to make these valid syntax)
or perform the substitution before printing the clauses