[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: one-of and other questions on goo's type system



Alexander S A Kjeldaas <astor@midten.trd.fast.no> writes:

> On Fri, Sep 20, 2002 at 03:13:06PM +0200, Benedikt Grundmann wrote:
> ...
> Speaking of Eiffel.  Is it possible to specify an eiffel 'like' type
> in goo?  It is something like:
> 
> (dg somefunc (arg1|<type1> arg2|(t= (typeof arg1))))
> 
> That is - whenever one calls somefunc, arg1 and arg2 must be of the
> same type (in eiffel - the static type so it's checked at compile
> time).  It also guarantees that if arg1 is a subtype of <type1>,
> somefunc will return the same subtype of <type1>.

i've uploaded james knight's masters thesis on parameterized types for
goo.  it does have of notion of linking parameter types and could also
be applied to generics.

jonathan

> In eiffel this is typically used for return values.  If you get an
> object into a function you want to return an object of the same type,
> so you want to say:
> 
> (dg dostuff-with-fruit (f|<fruit> => (typeof f)))
> 
> This is more precice than saying
> 
> (dg dostuff-with-fruit (f|<fruit> => <fruit>))
> 
> Consider:
> 
> (dc <fruit> (any))
> (dc <apple> (<fruit>))
> (dg dostuff-with-fruit (f|<fruit> => <fruit>))
> (dg dostuff-with-apple (a|<apple> => <apple>))
> (def apple (new <apple>))
> (dostuff-with-apple (dostuff-with-fruit apple))
> 
> In the above case, the type of the 'a' argument to dostuff-with-apple
> must be type-checked.  If dostuff-with-fruit was defined to return the
> same type as the input type, no such check would be necessary even if
> the definition of dostuff-with-fruit was unavailable.
> 
> astor