Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] extensible records again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] extensible records again
On Sun, 2004-03-21 at 17:21, Michael Vanier wrote:

> I've written a dynamically-typed language in ocaml, and I want to be able to
> add new types to the language without having to add new primitive types to
> the system. 

See Felix. The core system has NO primitive types,
not even bool: all primitive types are added by the user
(as bindings to C types).

> Now I want to add a type for (say) files.  I don't want this to be a type
> at the same level as ints or floats, because I want users to be able to add
> their own types to the language without hacking the core type definition.
> I can do this as follows:
>     (* types.mli *)
>     type data =
>         Int of int
>       | Float of float
>       | ...
>       | Extension of exn

You can just use:

	| Extension of string * address

where address is a machine address of some binary
data. What it is is completely irrelevant, since the
operations on user defined primitive data type
can only be specified in one way: by providing
C functions which manipulate that type.

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: