[Grace-core] another ambiguity in the grammar

Andrew P. Black black at cs.pdx.edu
Mon Mar 26 10:07:37 PDT 2012


As I recall, we have agreed (several times) that [1,2,3] is not a list literal.  MiniGrace may use it for bootstrapping; that's its own affair.  I'm concerned that we are letting the MiniGrace implementation drive the language, rather than the other way around.

I also recall that we agreed that [ ] would not be an operator in the lower language levels, and that collection indexing would use at() and at()put().   This correctly conveys to the student the idea that a collection is a single object and that any modification to it is an update on the whole object.  Thinking about arrays as collections of variables is one of the habits that C programmers have to be weaned away from.

We did consider making  [ ] a user-definable operator symbol in the higher language levels.   As Bart points out, this can be used for block application as well as collection indexing, or whatever the library-designer chooses.   I'm not convinced that we should make []:= a user-definable operator, though!  


On 25 Mar 2012, at 14:07, James Noble wrote:

> The spec currently allows (and minigrace supports)
> the [] operator method to index collections
> and [1,2,3] collection literals
> 
> so what's this a[1] indexing a, or calling a passing the literal collection [1]
> 

It's requesting the [] method on a, with the argument 1.  There is no literal collection syntax.

Which brings us back to the real question: varargs or tuples?

	Andrew


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20120326/c7a53fa1/attachment.html>


More information about the Grace-core mailing list