[Grace-core] another ambiguity in the grammar

James Noble kjx at ecs.vuw.ac.nz
Sun Mar 25 19:06:29 PDT 2012


On 26/03/2012, at 10:55 AM, Kim Bruce wrote:

> It shouldn't allow either!  Why is [ ] used for indexing collections?

syntatic compatibility with everything from Pascal to C#

>  Messages of the form get(i) seem perfectly fine to me.
>  I dislike the inconsistency in Java of accessing arrays differently from any other collection!

we're consistent: you can index any collection with []

> As we've also discussed, I'm not in favor of [a,b,c] for collection literals.  I'd rather write new List(a,b,c).

List.new(a,b,c)    ?

I probably should have been clearer - although in mini grace [1,2,3] 
are mutable collection literals, we recognize that as an aspect of bootstrapping.
If we want tuples and want to keep clear of argument lists then [1,2,3] is an option there. 

on option around the ambiguity is to care about whitespace: so "a[2]" is indexing, but "a [2]"
   passes [2] to a.

James


More information about the Grace-core mailing list