Browse thread
[Caml-list] Design advice
[
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 Hecker <checker@d...> |
| Subject: | Re: [Caml-list] Design advice |
> let suit_to_int = function
> | Spades -> 0
> | Hearts -> 1
> | Diamonds -> 2
> | Clubs -> 3
>? You only have to type it once, and if you change the constructors
>around, it won't even compile.
As I mentioned in my mail,
let suit_to_int = function
| Spades -> 0
| Hearts -> 1
| Diamonds -> 1
| Clubs -> 3
is a bug that the compiler can't find. That's why I said it was a
tradeoff. Also, having to type the constructors twice in the mli and the
ml is already a huge pain the ass for maintenance and refactoring in my
opinion, and having to do it a third time is completely lame. But yes,
magic is magic, so that's why I didn't say it was absolutely the right
thing. In reality, a ton of C code depends on this and it is documented to
work like this in the manual, so it's probably safe, but I don't like
fencing in the compiler folks any more than necessary. Hence, "choose your
poison".
Chris
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners