How to define new type in Oz ?

Torsten Anders torstenanders at gmx.de
Tue Mar 27 16:51:55 CEST 2007


Dear Vladimir,

A common way of defining a typ-checker for a newly defined "type" uses  
a name as in this example,

MyName = {Name.new}

class MyType
    feat !MyName: unit

    <rest of def>
end

/** %% Returns a boolean whether X is an Object with the  
class/superclass MyType.
%%*/
fun {IsMyType X}
    {Object.is X} andthen {HasFeature X MyName}
end

Best,
Torsten

On 27.03.2007, at 15:22, Jorge Marques Pelizzoni wrote:
> Hi, Vladimir! Indeed this is the way you can define a type having its  
> own
> Value.type result. However, you should notice that defining extensions  
> is
> meant to be something exceptional, not everyday practice. Usually  
> people
> go defining their own "types" (i.e. data structures, ADTs and even
> _classes_) on top of what already exists, the only thing being that
> Value.type won't recognize these new "types".
>
> Cheers,
>
> Jorge.
>
> Vladimir N. Dzhivsanoff escreveu:
>>
>>>
>>> On 3/26/07, Vladimir N. Dzhivsanoff <vdzh at yandex.ru> wrote:
>>>> Documentation tells that new type can be defined from Value or Chunk
>>> ?
>>>>
>>>>
>>>>
>>>> How to do it ?
>>>>
>>>>
>>>>
>>>> Some example:
>>>>
>>>>
>>>>
>>>> declare
>>>>
>>>> ....
>>>>
>>>> X= ...
>>>>
>>>> {Browse {Value.type X}}
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> - Where saved type-id ?
>>>>
>>>> - How I can define X that {Vlaue.type X} != <any standard type> ?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Thanks a lot.
>>>> ____________________________________________________________________ 
>>>> _____________
>>>> mozart-users mailing list                             
>>>  mozart-users at mozart-oz.org
>>>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>>> I think you should take a look at
>>> http://www.mozart-oz.org/documentation/foreign/ 
>>> node22.html#chapter.extension
>>>
>>> There is some information on how to extend the vm with new types
>>> (chunks).
>>>
>>> Cheers,
>>>
>>>
>>> --
>>> Gustavo Gutierrez
>>> _____________________________________________________________________ 
>>> ____________
>>> mozart-users mailing list                             
>>>  mozart-users at mozart-oz.org
>>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>>>
>>>
>>
>> Thank you.
>> ______________________________________________________________________ 
>> ___________
>> mozart-users mailing list
>> mozart-users at mozart-oz.org
>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>>
>
>
> Jorge M. Pelizzoni
> ICMC - Universidade de São Paulo
>
> _______________________________________________________________________ 
> __________
> mozart-users mailing list                                
> mozart-users at mozart-oz.org
> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>
>
--
Torsten Anders
Sonic Arts Research Centre • Queen's University Belfast
Frankstr. 49 • D-50996 Köln
Tel: +49-221-3980750
http://strasheela.sourceforge.net
http://www.torsten-anders.de



More information about the mozart-users mailing list