[Grace-core] Minutes of Teleconference 2011.08.17

Andrew P. Black black at cs.pdx.edu
Tue Aug 23 05:51:29 PDT 2011


The examples are usually more instructive if one uses real names.

On 19 Aug 2011, at 04:01 , James Noble wrote:

>> Factory[SomeType].new(...)  :  GenType[SomeType]

So that would be something like

Set[Person].empty : SetType[Person]

Set[Person].withElements(Fred, Kate, Pat) : SetType[Person]

These make sense if [ ] is a method name that works on the object Set (a factory) and on the type-generator SetType (which may or may not be an object; that's another discussion).

>> 
>> Doesn't that seem more parallel?  
> 
> sure it does - but now - especially with the "rewrite into object literals" story,
> we don't have a good account of what the Factory is, or how the [SomeType] works.
> 
> If we did have a "[]" operator, then we could actually handle things as you suggest
> (Michael and I talked about this yesterday) 

The alternative (if [ ] is not a method name) is to insert a method name; I suggest "of". Then we get:

Set.of(Person).empty : SetType.of(Person)

Set.of(Person).withElements(Fred, Kate, Pat) : SetType.of(Person)

or, if we don't require those parens around arguments:

(Set.of Person).empty : SetType.of Person

(Set.of Person).withElements(Fred, Kate, Pat) : SetType.of Person

> 
>> Just as GenType by itself is not a type (stomp out "erasures"!), so Factory by itself is not a class.  Both are functions from types to types/classes.
> 
> sure. Note that we can't really "stomp our erasures" if we wish to have collections
> (or more generally, generic classes or whatever we call them) that work both
> statically & dynamically typed.  I fear we need to write GenType meaning GenType[dynamic]
> for each of GenTypes' type parameters. 

This is a good observation.  What you are noticing is that in the above code, the Types are no longer just annotations, but also arguments to (compile-time) method-requests.  It would be better if we could write

Set.empty : SetType.of(Person)

Set.withElements(Fred, Kate, Pat) : SetType.of(Person)

Where the factory object (Set) does not take the type parameter explicitly, but rather it is deduced from the type annotation.  Is this possible?

	Andrew



More information about the Grace-core mailing list