Closed crusso closed 3 years ago
@rossberg so I'd like to fix this.
My plan is to introduce a dedicated syntax.ml
expressions node, RecE
, for record literals,
exp =
...
| RecE of rec_field list
rec_field =
| Field of id * exp
| VarField of id * exp
that takes the (possibly mutable) fields and type checks and desugars them directly. No visibility/stability modifiers or patterns required.
The parser (including the deprecated productions) would no longer desugar record literals to blocks yielding objects (freshening field names to avoid recursion) but parse directly to RecE
, simplifying lots of the productions and removing some desugaring from the parser.
Sound like a plan or did you have something else in mind?
Sounds good to me!
(Yay! Another step closer to being able to program in "real CBPV" within "core Motoko expressions"; we lacked the form that you are adding, among some others still missing.)
(Yay! Another step closer to being able to program in "real CBPV" within "core Motoko expressions"; we lacked the form that you are adding, among some others still missing.)
Not sure what CBPV has to do with it, but what's missing? Enquiring minds want to know!
Not sure what CBPV has to do with it, but what's missing? Enquiring minds want to know!
Oh, I'm so glad that you asked!
CBPV is, in my view, a "sweet spot" for the following design goals that PL people often find themselves with:
The key departures from the usual CBV core calc that most people would choose:
Thanks! I think here the issue was not having an introduction form for record since birectional checking seems to pivot on those. It was the same thing that made me uncomfortable with the suggestion to extend '? exp' to allow '!' escapes since it would no longer be an intro form. The fact that CBPV is closed under substitution should indeed make it good for optimization in a similar way that Kennedy argued continuations were better than ANF.
Rossberg writes:
This is an artefact of treating these as sugar for let blocks. With our recent semantic change, we could in principle change that, by having dedicated typing rules for the short form.