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
Re: [Caml-list] ocaml and named constants
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-06-01 (17:02)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] ocaml and named constants
Luc Maranget wrote:

> But I have another remark as far a ``manifest constants'' are the issue, Polymorphic
> variants seem to do the job.
> After all, provided you do not care much about the actual value of Foo)
> you can write :
> match x with
> | `Foo -> ...
> | `Bar -> ...
> | _    -> ...

In the 'real world' the constants are often integers or strings
whose values are dictated by standards, and this technique
requires providing two functions to map the value to and
from variants.

Sometimes this is OK. Sometimes, it is a problem: for example
the library Posix support is lacking all the error codes
and socket options available on some platforms,
and there is no workaround (other than magic).

John (Max) Skaller,
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper
download Interscript
To unsubscribe, mail  Archives: