[Grace-core] Some comments from Tijs on parsing Grace

James Noble kjx at ecs.vuw.ac.nz
Wed Jul 27 03:23:00 PDT 2016


On 27/07/2016, at 22:14PM, Tijs van der Storm <storm at cwi.nl> wrote:

> Hmm. Personally, I think longest match on parentheses is bad, since it does not match how we normally write parentheses/bracketing constructs.

fair enough - and let's be clear, I don't like [[ much but it was the best of the alternatives we (for some definition of "we") could agree upon (for some definition of "agree upon")

I don't think I mentioned this on the list - I think it's in the spec github which anyone can read - when we dropped varargs, introduced arity overriding, and added lineups (pretty much simultaneously)  the reason we added lineups was because we though we needed them for collection literals without varargs.

What I at least only realised later --- and I don't recall anyone mentioning it at the time-- - is that we could have just done the first two, and then done the  same literals as with varargs but with multiple definitions on the receiver side.
I at least prefer that design to the one with lineups.

> Moreover, I can't define my own brackety things, so the analogy with operators is only partial. 

you could once, in Kernan.

> Btw, reminds me, I once had a language design where , (comma) was just an infix binary operator, and bracketing using [] was unary around-fix operator. The comma then would create a shallow line-up like object, the bracket converted it to a list/array; same with {} for sets. (You weren't allowed to use comma expressions in param lists directly, but with parentheses you'd just get the shallow line-up). The only problem is that you couldn't write empty lists or set using the bracket notation.

Ha!  Andrew will probably tell us Smalltalk does that.
Self did something similar with && which was a sort of "flat cons"
it lifed two objects into a "collection building" except that two collection buildrers flattened themselves out (aka flat cons). I'd say it was Monadic
except that Tim & Wadler would yell at me. 

I can't remember if Kernan supported empty lists operators: wouldn't surprise me.  

The catch with doing this for Algol style parameter lists is that (in a dynamically typed world) a method taking a single parameter will bind 
fine for both a single object argument, or a single "lineup" containing one or more objects - but the thing bound to the arguments will be unexpectedly different.   There's also the Python "trailing ,"  syntax to create a oneple. 

J




More information about the Grace-core mailing list