Subject: Re: publish
From: Vassily Litvinov (vass@cs.washington.edu)
Date: Sun Apr 01 2001 - 16:09:00 PDT
Forgot to comment on a new feature that I introduced. You can use types
and synonyms as abbreviations for type constraints as follows.
Example one. Imagine you have
abstract object mydatatype[T1,T2]
where ... bunch of constraints on T1,T2,T3, ...;
Then you can say, for example:
method foo(x:T1,y:T2):void where mydatatype[`T1,`T2] { ... }
this "where" clause would incorporate all the constraints that mydatatype has.
Example two. Imagine you have a bunch of signature constraints which
you'd like to abbreviate. Then you say:
type synonym mysigs[T1,T2]
where signature S1 ...,
signature S2 ...;
Then saying, for example:
method foo(x:`T1,y:int):void where mysigs[T1,int] { ... }
would incorporate all signatures associated with mysigs synonym
in the type context of "foo".
You can go wild w.r.t. implicit type variables, backquotes, etc.
On a different topic, here are a couple of clarifications to what I said
earlier:
- my earlier statement that we are back to the set of keywords that had
been there before is mistake. Now we have the new keyword "synonym".
- even though desugaring of synonyms performs syntactic substitution,
semantic checking is performed at synonym definition time (so that
desugaring is always a type). If someone has any suggestions for a
different way to desugar type synonyms, I'd be interested to hear.
A random idea just occurred to me: in sufficiently advanced type system
there would be no need for synonyms: instead the programmer would define a
new type that's both a subtype and supertype of some other type. That way
the two types would be synonymous.
Vass
_______________________________________________
Cecil mailing list
Cecil@cs.washington.edu
http://majordomo.cs.washington.edu/mailman/listinfo/cecil
This archive was generated by hypermail 2b25 : Sun Apr 01 2001 - 16:10:04 PDT