caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pierre Weis <pierre.weis@inria.fr>
To: warplayer@free.fr (Nicolas Cannasse)
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Matching when
Date: Mon, 5 Aug 2002 15:05:54 +0200 (MET DST)	[thread overview]
Message-ID: <200208051305.PAA22009@pauillac.inria.fr> (raw)
In-Reply-To: <000f01c23c62$3ec98150$0700a8c0@warp> from Nicolas Cannasse at "Aug 5, 102 11:26:57 am"

Hi !

> I was thinking that the following should be possible :
> 
> match e with
> | Any
> | Int x when x > 0 ->
>         .... (* here we don't use x *)
> | ....
> 
> But the typechecker reject it because of the unbound 'x' in the "Any"
> matching.
> I don't know what kind of difficulty this modification require, but it would
> be nice if the compiler was able to resolve such cases.

I would require to analyze the set of free variables of expression
parts of match clauses to restrict the checks on variables of patterns
to this set of variables. In this case, the set of (typed) variables of
all the patterns of an ``or'' pattern should have the same intersection
with the set of free variables of the corresponding expression of the
clause, and this would solve your problem in a simple and elegant way.

This is simple and does not involve any modification of the semantics
of the language or of the pattern matching algorithm.

Regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
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


  parent reply	other threads:[~2002-08-05 13:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05  9:26 Nicolas Cannasse
2002-08-05  9:41 ` Luc Maranget
2002-08-05 16:13   ` John Max Skaller
2002-08-05 19:29     ` Luc Maranget
2002-08-05 20:16       ` [Caml-list] Sharing Files between OCaml and C Michael Tucker
2002-08-06 13:04         ` Olivier Andrieu
2002-08-06 14:01           ` Bruno.Verlyck
2002-08-06 18:50             ` Lex Stein
2002-08-07 11:40               ` Bruno.Verlyck
2002-08-05 13:05 ` Pierre Weis [this message]
2002-08-05 15:50 ` [Caml-list] Matching when John Max Skaller
2002-08-05 16:02 ` Remi VANICAT
2002-08-05 16:23   ` John Max Skaller
2002-08-05 18:25 ` Oleg
2002-08-06  6:37   ` Florian Hars

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=200208051305.PAA22009@pauillac.inria.fr \
    --to=pierre.weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=warplayer@free.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;
as well as URLs for NNTP newsgroup(s).