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] enums in OCaml?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-06-14 (08:15)
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?

Bug reports:  FAQ:
To unsubscribe, mail  Archives: