Title
#thinking-together
y

yairchu

07/14/2019, 12:23 PM
@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 -
12:24 PM
If I change the name of the “next” variable to “hi” the record becomes with the non-sugared syntax.
12:25 PM
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
Nick Smith

Nick Smith

07/14/2019, 12:27 PM
I guess you could consider it the same thing as the "code folding" feature that many IDEs provide
y

yairchu

07/14/2019, 12:31 PM
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

eyal

07/14/2019, 12:38 PM
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
Nick Smith

Nick Smith

07/14/2019, 12:41 PM
Sure, but it's the same principle: take the source code and display it slightly differently
12:41 PM
I'd say code folding is "simple" sugaring whereas this is more advanced
12:41 PM
and in the case of Lamdu the source code is the AST
y

yairchu

07/14/2019, 12:42 PM
However code folding tries to give you more choices while we try to reduce choices
d

Drewverlee

07/14/2019, 11:09 PM
What does "the dual of macros" mean?
11:10 PM
How is code folding giving you more choices?
y

yairchu

07/15/2019, 6:26 AM
@Drewverlee The choices code folding gives the reader is whether to view things expanded or collapsed