Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: e@flavors.com (Doug Currie, Flavors Technology, Inc.)
To: Christophe Raffalli <raffalli@cs.chalmers.se>, Michel.Mauny@inria.fr
Cc: tarizzo@world-net.sct.fr, caml-list@margaux.inria.fr
Subject: Re: Why no macros in CAML Light ?
Date: Wed, 15 Nov 1995 15:33:54 -0500	[thread overview]
Message-ID: <v0151010caccff9db65eb@[204.5.215.14]> (raw)


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






             reply	other threads:[~1995-11-16  7:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-11-15 20:33 Doug Currie, Flavors Technology, Inc. [this message]
  -- strict thread matches above, loose matches on Subject: below --
1995-11-15 20:23 Hubert Canon
1995-11-14 23:43 Tarizzo Martial
1995-11-15  9:36 ` Pierre Weis
1995-11-15 15:28   ` Michel Mauny
1995-11-15 17:02     ` Vale'rie Me'nissier-Morain
1995-11-16 13:00       ` U-E59264-Osman Buyukisik
1995-11-15 17:43     ` Christophe Raffalli
1995-11-15 13:44 ` U-E59264-Osman Buyukisik

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='v0151010caccff9db65eb@[204.5.215.14]' \
    --to=e@flavors.com \
    --cc=Michel.Mauny@inria.fr \
    --cc=caml-list@margaux.inria.fr \
    --cc=raffalli@cs.chalmers.se \
    --cc=tarizzo@world-net.sct.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