From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA08100; Thu, 31 May 2001 11:22:53 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA08061 for ; Thu, 31 May 2001 11:22:52 +0200 (MET DST) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f4V9Mpb16878; Thu, 31 May 2001 11:22:51 +0200 (MET DST) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id LAA0000007458; Thu, 31 May 2001 11:22:50 +0200 (MET DST) From: Luc Maranget Message-Id: <200105310922.LAA0000007458@beaune.inria.fr> Subject: Re: [Caml-list] ocaml and named constants To: bpr@best.com (Brian Rogoff) Date: Thu, 31 May 2001 11:22:50 +0200 (MET DST) Cc: Luc.Maranget@inria.fr (Luc Maranget), skaller@ozemail.com.au (John Max Skaller), caml-list@inria.fr In-Reply-To: from "Brian Rogoff" at mai 30, 2001 09:50:13 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > On Tue, 29 May 2001, Luc Maranget wrote: > > > > > > Is there any semantic reason why > > > one cannot use variables, or even expressions? Apart from > > > the obvious syntactic problem. > > > > Not that obvious, I think this would make pattern-matching look > > like even more complicated. > > It is good to stress on the fact that > > in match .. with p ->, p is a pattern > > 1. Some value ``whith holes'' > > 2. Something we programmer and compiler know without any computation. > > I read a paper on an SML extension to handle this named constant problem, > here at ftp://ftp.research.bell-labs.com/dist/smlnj/papers/92-tr-aitken.ps > Anyone know why this or some similar approach hasn't caught on? The CamlP4 > approach isn't too bad, but this seems important enough to be in the core > language. > > This is certainly on my "wish list" for future enhancements, since there > are so many cases where named constants are useful and the current > workarounds are a bit ugly. > > -- Brian > > I got the reference and the idea (I think). These are the so-called ``macros (that work!)'' They give you 1- Mandatory optimizations (aka inlining) 2- A different syntax for function and constructor application both in patterns. Stuff for making all that cross module boundaries (allowing data abstraction and pattern-matching to cohabit) looks a bit complicated and may not be what you want. But I have another remark as far a ``manifest constants'' are the issue, Polymorphic variants (http://caml.inria.fr/ocaml/htmlman/manual003.html) seem to do the job. After all, provided you do not care much about the actual value of Foo) you can write : match x with | `Foo -> ... | `Bar -> ... | _ -> ... In place of const Foo = 0 const Bar = 1 match x with | Foo -> ... | Bar -> ... | _ -> ... --Luc ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr