Interpret result-less blocks as dicts #3490
Labels
Language
Regarding Squiggle language semantics, distributions and function registry
stage:proposal
A proposal that warrants discussion whether we want to implement it
This is my old proposal that I want to raise again; we could interpret this code:
As this:
Rationale
AI
Squiggle AI has the tendency to write code like this:
Probably because of our own style guide.
Tagging dict entries
We can implement decorators on dict entries in their original form, but there might be possible negative consequences.
When parsing, we should attempt to resolve ambiguity as quickly as possible, and the situation like this:
is ambiguous until the parser encounters the next symbols and sees if it's
:
or=
.This is probably not a big issue, but I'm not 100% sure.
Supporting tags only for block-style dicts, on the other hand, doesn't require any new syntactic features.
Debugging
Imagine you're working on this function:
But it doesn't do what you expect it to do.
With this feature, you could comment the last line, and get the version of the function that exposes all its variables. (This would be especially convenient combined with auto-calculators, which we still don't have, but even without that, you could write something like
debugF = f(1)
immediately below.)Convenience
Commas are annoying :)
If all your keys are valid identifiers, then this new syntax might be easier to write.
The text was updated successfully, but these errors were encountered: