[Grace-core] Minutes of Teleconference 2011.08.17
James Noble
kjx at ecs.vuw.ac.nz
Tue Aug 23 14:40:52 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).
sure --- but this also means just writing Set[Person] has to have some operational semantics.
We'd have some objects (say "ground classes" which are *not* generic) like "Person"
other objects denoting generic classes like "Set"
then requesting the [] method on a generic class like Set gives a ground class...
> 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
partly- but also that we actually have two kinds of class-like things...
*and then* due to wanting implicit dynamic parameterisation,
in dynamically typed code, we have to treat a generic class as if it was a ground class
(yes this is quite like raw types in Java, perhaps exactly like it, which is bad because they are a Bad Thing)
> Where the factory object (Set) does not take the type parameter explicitly, but rather it is deduced from the type annotation. Is this possible?
yes it is possible - the question is how much annotation we want to do
and in what "direction".
So far, we've talked about inferring
- types from initialisers to variables
- Java style types for lambda expressions
- Java style implicit method generic parameters
We could do it but it would add another case to that list, I think.
that's where the idea of creation via generic *methods* come from.
and, again, if [] is an operator - which I quite like for mostly other reasons -
these inferences come down to inserting implicit / magic insertion of calls to it,
which I'm less keen on, at least if they are naively visible to the programmer
James
More information about the Grace-core
mailing list