From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: Julian Assange <proff@iq.org>
Cc: caml-list@inria.fr
Subject: Re: polymorphic variant oddity
Date: Sun, 8 Oct 2000 19:22:02 +0200 [thread overview]
Message-ID: <20001008192202.A6794@miss.wu-wien.ac.at> (raw)
In-Reply-To: <wxitr4naws.fsf@suburbia.net>; from proff@iq.org on Sat, Oct 07, 2000 at 22:33:23 +1100
On Sat, 07 Oct 2000, Julian Assange wrote:
> let `F x = x;;
> Unbound value x
> # let `F x = 1;;
> This expression has type int but is here used with type [< `F of 'a | ..]
> # let `F x = `F 1;;
> val x : int = 1
> # `F 4;;
> - : [> `F of int] = `F 4
>
> What exactly is the meaning this?
This is the same as saying, e.g.:
let Some x = Some 3;;
"x" will be bound to "3".
"let", too, can be used for pattern matching. Of course, one can only match
one pattern at a time with it, which rules it out for sum types that have
several instances (as in the above example -> "Some/None"): a match error
may occur.
Normally, this kind of pattern matching is only used for patterns that
never fail ("irrefutable patterns"), e.g. tuples:
let x, y = 1, 2 in ...
Best regards,
Markus Mottl
--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
next prev parent reply other threads:[~2000-10-08 21:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-07 11:33 Julian Assange
2000-10-08 16:00 ` Pierre Weis
2000-10-08 17:22 ` Markus Mottl [this message]
2000-10-08 20:09 ` John Prevost
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=20001008192202.A6794@miss.wu-wien.ac.at \
--to=mottl@miss.wu-wien.ac.at \
--cc=caml-list@inria.fr \
--cc=proff@iq.org \
/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