Browse thread
[Caml-list] enums in OCaml?
[
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: | Chris Quinn <cq@h...> |
| Subject: | Re: [Caml-list] enums in OCaml? |
A recent thread on the subject: http://caml.inria.fr/archives/200105/msg00168.html There's mention of an SML extension that solves this problem (ie. retaining the good typing properties). Are the Caml designers considering this? Chris Q. leary@nwlink.com wrote: > > Ok, I see how I can do this with a sum type and a function on it; but > that's also a lot of repetitive setup. Seems I could also just make a > function that acted on strings: > > let message_to = function > "accel" -> 1 > | "stop" -> 0 > | _ -> -1;; > > ...which is perhaps less typing/editing up front, but a bit of a pain to > type all the "s in the code. > > So, what's so wrong with just using variables? > > let Accel = 1;; > let Stop = 0;; > > seems pretty short to write and shortest to use... Am I missing something > ( elegant | obvious )? Is that just ugly? > > thanks ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr