<@UCGAK10LS> To demonstrate the concept of “projec...
# thinking-together
y
@Nick Smith To demonstrate the concept of “projectional syntax sugar” a bit more - here’s a simple example: The record below is equivalent to
{prev: num, next}
in JavaScript or
{prev = num, next}
in Haskell with
NamedFieldPuns
- the “next” field is set to the value of the variable with the same name -
👍 1
If I change the name of the “next” variable to “hi” the record becomes with the non-sugared syntax.
🤯 1
btw afaik “Projectional Syntactical Sugar” is a unique feature in Lamdu which me and @eyal invented. If it exists anywhere else I’d love to hear about it
n
I guess you could consider it the same thing as the "code folding" feature that many IDEs provide
y
To me folding feels different. It’s a mode of viewing and is maybe more related to turning type or value annotations on or off - it doesn’t affect the code but how you view it. In Lamdu if the code fits the pattern then it will always be displayed sugared. Caveat: the syntactical sugars are toggle-able in the configuration file and perhaps in a gamified tutorial in the future the sugars will be enabled one by one as you learn them. Btw some basic stuff like “if expressions” are just syntax sugar for pattern matching
e
Code folding only hides things whereas sugar does less trivial changes to how things are shown when they match a pattern, like the dual of macros
n
Sure, but it's the same principle: take the source code and display it slightly differently
I'd say code folding is "simple" sugaring whereas this is more advanced
and in the case of Lamdu the source code is the AST
y
However code folding tries to give you more choices while we try to reduce choices
👍 1
d
What does "the dual of macros" mean?
How is code folding giving you more choices?
y
@Drewverlee The choices code folding gives the reader is whether to view things expanded or collapsed