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: | leary@n... |
| Subject: | Re: [Caml-list] enums in OCaml? |
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