From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id IAA27183 for caml-redistribution; Thu, 16 Nov 1995 08:50:49 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.6.10/8.6.6) with ESMTP id VAA20171 for ; Wed, 15 Nov 1995 21:34:57 +0100 Received: from margaux.inria.fr (margaux.inria.fr [128.93.8.2]) by concorde.inria.fr (8.7.1/8.6.9) with ESMTP id VAA29083 for ; Wed, 15 Nov 1995 21:34:56 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by margaux.inria.fr (8.6.10/8.6.6) with ESMTP id VAA13778 for ; Wed, 15 Nov 1995 21:34:56 +0100 Received: from uu3.psi.com (uu3.psi.com [38.145.250.2]) by concorde.inria.fr (8.7.1/8.6.9) with SMTP id VAA29079 for ; Wed, 15 Nov 1995 21:34:50 +0100 (MET) Received: from flavors.com by uu3.psi.com (5.65b/4.0.940727-PSI/PSINet) via SMTP; id AA19276 for caml-list@margaux.inria.fr; Wed, 15 Nov 95 15:34:33 -0500 Received: from [204.5.215.14] by flavors.com with SMTP (MailShare 1.0fc6); Wed, 15 Nov 1995 15:34:22 -0500 Message-Id: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Wed, 15 Nov 1995 15:33:54 -0500 To: Christophe Raffalli , Michel.Mauny@inria.fr From: e@flavors.com (Doug Currie, Flavors Technology, Inc.) Subject: Re: Why no macros in CAML Light ? Cc: tarizzo@world-net.sct.fr, caml-list@margaux.inria.fr Sender: weis At 6:43 PM 11/15/95, Christophe Raffalli wrote: >> Even simpler: use the C preprocessor itself! (with the -P option) >> I know, it is tractable only under Unix, and using Makefiles... > >I do it on my mac .... Not with CodeWarrior :-( which seems to require C syntax in the preprocessor. Do you use MPW? I would like to see a simple macro mechanism in Caml Light (and other ML languages) to avoid the use of cpp and make. One possibility... LISP has an intermediate mechanism between preprocessor and full compiler macros, reader macros. A particular set of reader macros "#+" and "#-" are useful for the types of things the C preprocessor does. A simplified description of how they work could work in ML is as follows: The compiler maintains a list of "features." Interactive user code, or makefiles, or other mechanisms, may add to the features list -- it is just an ML list of strings. The reader (lexer) treats the #+ and #- tokens specially. If the token following the #+ is a string on the features list, then the next token [expression] is processed, otherwise it is discarded. If the token following the #- is a string not on the features list, then the next token [expression] is processed, otherwise it is discarded. This doesn't require any change to the compiler per se (just the lexer) and does not require an "eval" mechanism. For example, to distinguish constants for 32 bit versus 64 bit implementations, you could use: let size = #+"32bit" 0x40000000 #+"64bit" 0x4000000000000000 For a function only available in UNIX implementations: #+"UNIX" ( let chmod file xxx = ... ;; ) Or for a function not available on the Mac: #-"Macintosh" ( let system str = ... ;; ) e