[Grace-core] Names for the […] literal

James Noble kjx at ecs.vuw.ac.nz
Mon Feb 8 18:27:55 PST 2016


A couple of points after talking to Michael last friday
(and it’s been a holiday long weekend since then!)

1. [] vs varargs 

I recall michael said something like: 

> it’s an odd thing to put a collection into a pure OO language

what I’d have said at the time, if I’d thought of it, is 

"yes it is, but both varargs and collection literals have that same problem. 
The question is where and how to put a collection in — or whether ot take it right out —

Varargs puts in the * syntax on arguments, and will bind instances of the collection 
to formal variadic parameters.  Michaels expanded message syntax uses even more
of those collections. 

Collection literals puts in the [..] literal syntax, but the argument binding is “standard”. 





2. varargs and types

michael raised the issues of the type lattice: without varargs, the type lattice
could be incomplete. This is (I think, partly) where andrew’s plan for overriding
on  arity comes from. 

given 

> type one { foo(x) }
> type two { foo(x ,y{ } 

what is 

> type three = one & two 

I think there are a range of bad options here: 

option 1 - ban all overloading in both types and method
 intersection types (like “three”) don’t exist

option 2 - permit overloading in types but NOT in objects
 so intersection types will exist but are uninhabitable

option 2a - like option 2 but still forbid writing them out, so 
"type three = one & two “ would be legal, but 

> type threeA = {
>   foo(x)
>   foo(x, y)
> } 

would be illegal.

3 - permit overloading in both types and objects

so

> object {
>  foo(x) { print “one” }
>  foo(x,y) { print “two” }   //overloads

would now be legal. 

option 3a - like option 3 but the standard dialect would forbid bulding objects that use overloading







More information about the Grace-core mailing list