[Grace-core] Minutes of Teleconference 2012.01.10-11

James Noble kjx at ecs.vuw.ac.nz
Thu Jan 12 00:20:38 PST 2012


> I'm rethinking my position on the syntax for class constructs.  The current proposal is 

OK...

> class CountingStackClass.new<T>(size : Number, bottom : Number) -> CountingStack<T> {
> inherits StackClass.new<T>(bottom) 
>     // permitted via "definitively static" 
> var count:= 0;
> override method push ...
> ...

yep, and that (pretty much) works on minigrace, thanks to Michael!
(actually it worked yesterday, but we're beating a few bugs out)

> I'd rather see 
> 
> class CountingStackClass<T>(size : Number, bottom : Number) -> CountingStack<T>
> inherits StackClass<T>(bottom) {
>     // permitted via "definitively static"
> var count:= 0;
> override method push ...
> }
> 
> Advantages:
> 1.  Threw away two noisy occurrences of “.new”.

right except - 
 one of them named the CountingStackClass constructor method
 the other one named the StackClass constructor method

what comes after "inherits" is now special, it's not an expression,

and CountingStackClass<T>(size : Number, bottom : Number) - or rather

"CountingStackClass<T>(s,b)" --- the actual instantiation of that bit of syntax
*isn't* legal, if we still have to put the "new" back in.

> 2.   Putting “inherits StackClass” outside of  curly brackets is more similar to type constructions:
>             type ExtType = SomeType & {m(T) -> U, …}

yes, I can see that.
putting inherits inside is more similar to declarations, though  (you can think of the declarations being copied).
I don't think this should be a big thing though!

> 3.   Resulting syntax is closer to existing languages (but we would still use CountingStackClass.new<T>(args) to call the constructor and the translation to objects would be exactly the same).

right - so I really don't like the inconsistency with this design

> James called a minor variant of this "encoding classes as methods" (with a different encoding), but I don't see the need for that.

basically we should be consistent -  I can see three consistent designs from where we are (without going a lot further)

1. -the current proposal: 

> class CountingStackClass.new<T>(size : Number, bottom : Number) -> CountingStack<T> {
> inherits StackClass.new<T>(bottom) 

called as 

>  CountingStackClass.new<Thing>(s,b) 


2. -the method-encoded proposal:

> 
> class CountingStackClass<T>(size : Number, bottom : Number) -> CountingStack<T> {
> inherits StackClass<T>(bottom) 

called as 

>  CountingStackClass<Thing>(s,b) 

3. -a Dart like proposal with *no* single distinguished constructor, but permitting multiple factory methods
I think we had this earlier, I'm sure we could cons it up again now, something like 
       
> class CountingStackClass  inherits StackClass<T>.new(bottom)  {
>   factory method new<T>(size : Number, bottom : Number) -> CountingStack<T>  { ... } 

and yep, to make this work I think all the parameters go on the methods & types, not on the class

J



More information about the Grace-core mailing list