From: michaelgrunewald@yahoo.fr (Michaël Grünewald)
To: "Damien Guichard" <alphablock@orange.fr>
Cc: "Liste de diffusion OCaml" <caml-list@inria.fr>
Subject: Re: [Caml-list] Variants & structural ordering
Date: Wed, 06 Feb 2008 09:21:47 +0100 [thread overview]
Message-ID: <864pcmze90.fsf@Llea.celt.neu> (raw)
In-Reply-To: <20080205081845.2D24D1C02531@mwinf2341.orange.fr> (Damien Guichard's message of "Tue\, 5 Feb 2008 09\:21\:21 +0100")
"Damien Guichard" <alphablock@orange.fr> writes:
> Hi everybody,
>
> Typically, when you declare:
>
> type card =
> | Card of int
> | Jack
> | Queen
> | King
> | Ace
> ;;
>
> The relation you wish is:
>
> Card(2) < ...< Card(10) < Jack < Queen < King < Ace
>
> And that's what you get when using F#.
>
> However when using OCaml here is what you get:
>
> Jack < Queen < King < Ace < Card(2) < ...< Card(10)
>
> And the work-around is:
>
> type card =
> | Card of int
> | Jack of unit
> | Queen of unit
> | King of unit
> | Ace of unit
> ;;
>
> Is this a bug or a feature ?
> Will it change in a foreseable future ?
Conventions are always a bit arbitrary, aren't they? To me, the
natural order with cards are:
Card(7) < Card(8) < Queen < King < Card(10)< Ace < Card(9) < Jack
and
Card(7) < Card(8) < Card(9) < Jack < Queen < King < Card(10)< Ace
(yes there are two natural orders).
Furthermore, I tried your program on a host whose native charset is
KOBAIA-8 (a weird variation on EBCDIC), hold your breath:
F# behaves there just like OCaml does on your host, and vice-versa!
Computers are good at doing what they are told to, so why don't you
tell them?
The only purpose of a generic `compare' procedure os the easy use of
`Set.Make' and `Map.Make' with random types, isnt't it? It is very bad
to assume it giving any sensible order on non basic types, you sure
have to define `sensible' yourself.
--
Michaël
next prev parent reply other threads:[~2008-02-06 8:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-05 8:21 Damien Guichard
2008-02-05 9:47 ` [Caml-list] " Berke Durak
2008-02-05 9:48 ` Oliver Bandel
2008-02-05 15:04 ` Jon Harrop
2008-02-06 8:21 ` Michaël Grünewald [this message]
2008-02-07 15:50 ` Damien Doligez
2008-02-05 16:59 Damien Guichard
2008-02-05 17:25 ` Stéphane Lescuyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=864pcmze90.fsf@Llea.celt.neu \
--to=michaelgrunewald@yahoo.fr \
--cc=alphablock@orange.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox