From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA19002 for caml-red; Wed, 28 Jun 2000 17:43:50 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA01905 for ; Tue, 27 Jun 2000 21:12:57 +0200 (MET DST) Received: from shell5.ba.best.com (shell5.ba.best.com [206.184.139.136]) by concorde.inria.fr (8.10.0/8.10.0) with ESMTP id e5RJCuH21011; Tue, 27 Jun 2000 21:12:56 +0200 (MET DST) Received: from localhost (bpr@localhost) by shell5.ba.best.com (8.9.3/8.9.2/best.sh) with ESMTP id MAA03947; Tue, 27 Jun 2000 12:12:50 -0700 (PDT) Date: Tue, 27 Jun 2000 12:12:50 -0700 (PDT) From: Brian Rogoff To: Daniel de Rauglaudre cc: Remi VANICAT , caml-list@inria.fr Subject: Re: How to cleanly encode "quasi-constants"? In-Reply-To: <20000626124230.F23651@jaune.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis@pauillac.inria.fr On Mon, 26 Jun 2000, Daniel de Rauglaudre wrote: > Hello, > > On Fri, Jun 23, 2000 at 04:27:00PM +0200, Remi VANICAT wrote: > > > I have a question about this : is there a way to make easily a compile > > time constants? > > (if i have a let var = func constant_argument, and i know that this > > can't change from an execution to an other, i want it to be evaluated > > only once) > > You can use preprocessors: i.e. /lib/cpp (general) or Camlp4 (specific to > Ocaml). In Camlp4, you can do that with "quotations". (I am not sure that > "easily" is appropriate... :-): you have to learn how Camlp4 works). This is one of the many very useful features of CamlP4. The desire to do define compile time constants comes up a lot in my day-to-day programming, for instance when writing tools to process a particular file format which uses numbers to indicate types in some way (I'm thinking of GDSII here). One issue with using CamlP4 which has been brought up before is that there seems to be some emerging consensus on using ">>" and "<<" for function composition, and there is a clash with CamlP4's use of these tokens. Is there a good solution to this? I admit I'm also fond of the Revised syntax. Some of our users have a tough time with OCaml syntax (we have a program which is configured by a dynamically loaded file) and some of the changes of Revised (distinguishing let ... = ...;; from let ... = exp in ..., do .. return e, forced parenthesization of tuples, forcing "&&" and "||", ...) would have probably avoided some complaints from these users, who are mostly used to C, Perl, and Scheme syntaxes. -- Brian