From: Andreas Rossberg <rossberg@ps.uni-sb.de>
To: caml-list@inria.fr
Cc: John Max Skaller <skaller@ozemail.com.au>
Subject: Re: [Caml-list] ocaml and named constants
Date: Tue, 29 May 2001 14:12:38 +0200 [thread overview]
Message-ID: <3B139236.C2B435F0@ps.uni-sb.de> (raw)
In-Reply-To: <3B12F66C.5F5793F9@ozemail.com.au>
John Max Skaller wrote:
>
> > One motivation for this is to be able to put named constants in
> > patterns, e.g.
> >
> > match get_next_byte() with
> > mpg_joint_stereo -> ...
> > | mpg_78rpm -> ...
> > | _ -> ...
> >
> > which cannot be done in plain ML.
>
> Is there any semantic reason why
> one cannot use variables, or even expressions? Apart from
> the obvious syntactic problem.
If you allow arbitrary (dynamically determined) values to be matched
against, then pattern matching has unbound cost. It might not even
terminate in the presence of circular values. OTOH, with the current
form, the cost of pattern matching is always linear in the syntactic
size of the match. I think it is good design to have potentially costly
operations explicit.
Moreover, such matching would most likely rely on structural equality.
Although this is not a technical problem since OCaml already has
structural equality, I would at least consider it questionable to
promote its (implicit!) use through such a feature.
- Andreas
--
Andreas Rossberg, rossberg@ps.uni-sb.de
"Computer games don't affect kids.
If Pac Man affected us as kids, we would all be running around in
darkened rooms, munching pills, and listening to repetitive music."
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-05-29 12:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-23 17:06 David Fox
2001-05-28 12:32 ` Xavier Leroy
2001-05-29 1:07 ` John Max Skaller
2001-05-29 12:12 ` Andreas Rossberg [this message]
2001-05-29 17:16 ` John Max Skaller
[not found] ` <skaller@ozemail.com.au>
2001-05-30 9:46 ` Wolfgang Lux
2001-05-29 13:50 ` Luc Maranget
2001-05-30 16:50 ` Brian Rogoff
2001-05-31 9:22 ` Luc Maranget
2001-05-31 16:34 ` Brian Rogoff
2001-06-01 4:39 ` David Fox
2001-06-01 1:45 ` John Max Skaller
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=3B139236.C2B435F0@ps.uni-sb.de \
--to=rossberg@ps.uni-sb.de \
--cc=caml-list@inria.fr \
--cc=skaller@ozemail.com.au \
/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