caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Why no macros in CAML Light ?
@ 1995-11-14 23:43 Tarizzo Martial
  1995-11-15  9:36 ` Pierre Weis
  1995-11-15 13:44 ` U-E59264-Osman Buyukisik
  0 siblings, 2 replies; 9+ messages in thread
From: Tarizzo Martial @ 1995-11-14 23:43 UTC (permalink / raw)
  To: caml-list


*** French translation follows ***
Hello,

Using LISP-Like language (SCHEME to be more precise), I wonder why there is
no macro facility in CAML. This would provide some syntactic sugar which
could answer some problems or suggestions encountered in caml-list (lack or
improvment of control structure, etc...)

I know that the very simple (and uniform) syntactic structure of lisp
programs permits an easy coding of complex macros, but it would be nice to
have at least in caml the equivalent of what can be found in procedural (and
compiled) languages : C for example. 

Perhaps, there are implementation problems related with the type system of
CAML, but I can't figure out what they are : the only job of a
"preprocessor" is to translate a phrase in core CAML, not to deal with types.

*****
Bonjour,

Utilisant un langage Lispien (SCHEME pour etre plus precis), je me demande
pourquoi il n'existe pas en CAML la possibilite de programmer des macros.
Cela pourrait fournir du "sucre syntaxique" afin de resoudre quelques
problemes ou suggestions rencontrees dans la liste CAML (ajout ou
amelioration des structures de controle, etc...)

Il est vrai que la syntaxe tres simple (et uniforme) de Lisp facilite le
codage de macros complexes, mais il serait agreable de disposer au moins de
l'equivalent de ce qu'on peut trouver dans les langages proceduraux (et
compilables) classiques : C par exemple.

Il existe peut-etre des problemes d'implementation lies au systeme de
verification de types de CAML, mais je ne vois pas trop lesquels : le seul
travail d'un "preprocesseur" est de traduire une phrase en CAML de base,
sans s'occuper des types.

Merci d'eclairer ma lanterne.
*********************************
 Tarizzo Martial
 Prof. Sc Physiques
 Classes preparatoires
 Lycee J MOULIN
 57600 FORBACH

 Email: tarizzo@world-net.sct.fr
        74014.3307@compuserve.com
 Compuserve : 74014,3307
*********************************





^ permalink raw reply	[flat|nested] 9+ messages in thread
* Why no macros in CAML Light ?
@ 1995-11-15 20:23 Hubert Canon
  0 siblings, 0 replies; 9+ messages in thread
From: Hubert Canon @ 1995-11-15 20:23 UTC (permalink / raw)
  To: caml-list


> > Even simpler: use the C preprocessor itself! (with the -P option)
> > I know, it is tractable only under Unix, and using Makefiles...
> Furthermore cpp is not 8bits clean but Caml Light is so it would be a
> limitation to the expressivity of Caml Light.


There are other good preprocessors. For instance I use m4, which
exists in a DOS version too.

-- 
-------------------------- Hubert Canon --------------------------
        Email : canon@poly.polytechnique.fr
        WWW   : http://www.polytechnique.fr/poly/~canon/
------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: Why no macros in CAML Light ?
@ 1995-11-15 20:33 Doug Currie, Flavors Technology, Inc.
  0 siblings, 0 replies; 9+ messages in thread
From: Doug Currie, Flavors Technology, Inc. @ 1995-11-15 20:33 UTC (permalink / raw)
  To: Christophe Raffalli, Michel.Mauny; +Cc: tarizzo, caml-list


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






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1995-11-16 13:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-11-14 23:43 Why no macros in CAML Light ? 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
1995-11-15 20:23 Hubert Canon
1995-11-15 20:33 Doug Currie, Flavors Technology, Inc.

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