[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Brian Rogoff <bpr@b...> |
| Subject: | Re: [Caml-list] ocaml and named constants |
On Thu, 31 May 2001, Luc Maranget wrote: > But I have another remark > as far a ``manifest constants'' are the issue, Polymorphic > variants > (http://caml.inria.fr/ocaml/htmlman/manual003.html) > seem to do the job. > > After all, provided you do not care much about the actual value of Foo) Ah, the problem for me is that I really do care about the actual value for the constants. It turns out that I may process binary file formats (GDSII is the canonical example) where I want the name to correspond to a number. Of course, I can and do do it by hand (or use P4) by writing the equivalent of Ada's 'Pos and 'Val attributes for enumerated types. I would use plain old sum types too since I don't need them to be open for extension. It's a bit more cumbersome than I'd like it since I have to specify the mapping twice (constructor -> integer and integer -> constructor) which is cumbersome. -- Brian ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr