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

Re: Datatype-problem



Pieter,

> It's easy to extend every TYPE by an extra value as follows:
> 
> extend_it[T: TYPE]: DATATYPE
> BEGIN
>   new: new?
>   up(down: T): up?
> END extend_it
> 
> But now I want to use the extra value for the TYPE posnat:
> 
> new_theory: THEORY
> BEGIN
>   IMPORTING extend_it[posnat]
> value: new[posnat]               % This doesn't work!
> END new_theory

I suppose what you want to do is to introduce the name 'value' for
the extra value that extends posnat. However, your declaration

	value: new[posnat]

would introduce 'value' as an element of the _type_ new[posnat]. The
problem is, the expression new[posnat] doesn't denote a type, but a
value. You have to use the type of new[posnat] instead, which is
(new?[posnat]). The declaration thus should read

	value: (new?[posnat]) = new[posnat]

Hope this helps,

	- Holger

-- 
--------------------------------------------------------------------
Holger Pfeifer                           Tel.: +49 (0)731 / 50-24124
Universität Ulm                           Fax: +49 (0)731 / 50-24119
Abt. Künstliche Intelligenz         pfeifer@ki.informatik.uni-ulm.de
D-89069 Ulm         http://www.informatik.uni-ulm.de/ki/pfeifer.html   
--------------------------------------------------------------------