The type of an ArrayToken is {t} where t is least upper bound of the types of the elements.
We have talked about (and have a preliminary implementation of) a TupleToken, which is tuple of tokens that can have heterogeneous types. It is exactly like a RecordToken, except that instead of named fields, it has numbered fields. The type inference engine works fine with this...
Edward
At 08:11 AM 8/12/2004 -0700, Shawn Bowers wrote:
> TF> It looks (from comments in the source) like ArrayTokens are supposed to
> TF> have a type that is determined by the least upper bound of their
> TF> components, but because the code generator doesn't understand 'least upper
> TF> bound', the current implementation of arrays requires that all of the
> TF> elements have the same type exactly. (Otherwise you could have a
> TF> heterogeneous array, whose type would be elevated to {general}.)
>
> ouch... is that how Haskell and other Hindley Milner (HM) type systems
> would do it? But then again, maybe HM is not the best for the very
> flexible needs in a Ptolemy/Kepler like system... not sure..
In the Ptolemy expression language, you can give a "heterogeneous" array {0, 1.0, "foo"} and the inferred type is array of string (the most general concrete type, right under 'general').
>
> TF> An empty array created from "{}" could have type "{general}", and an empty
> TF> array created from subarray operations, or repeat(0,"foo"), could have
> TF> more specific types, and appending something to zero-length array could
> TF> have the type recomputed on the resulting array (neglecting the
> TF> non-element and its possibly 'general') type... eh?
>
> I think we should at least give HM a chance...
>
> all of these typing issues are very interesting and get even more so,
> as we start adding "semantics"...
>
> another day...
>
> Bertram
>
>
> TF>
> TF> ...
> TF>
> TF> Tobin
>
> ----------------------------------------------------------------------------
> Posted to the ptolemy-hackers mailing list. Please send administrative
> mail for this list to: [EMAIL PROTECTED]
>
_______________________________________________ kepler-dev mailing list [EMAIL PROTECTED] http://www.ecoinformatics.org/mailman/listinfo/kepler-dev
------------ Edward A. Lee, Professor 518 Cory Hall, UC Berkeley, Berkeley, CA 94720 phone: 510-642-0455, fax: 510-642-2739 [EMAIL PROTECTED], http://ptolemy.eecs.berkeley.edu/~eal
---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]