Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!bbn!rochester!udel!burdvax!zeta!lang
From: lang@zeta.PRC.Unisys.COM (Francois-Michel Lang)
Newsgroups: comp.lang.prolog
Subject: Re: Why no macro facility?
Message-ID: <6877@burdvax.PRC.Unisys.COM>
Date: 8 Jul 88 12:54:11 GMT
References: <9671@lll-winken.llnl.gov>
Sender: news@PRC.Unisys.COM
Organization: Unisys Corporation, Paoli Research Center; Paoli, PA
Lines: 31

In article <9671@lll-winken.llnl.gov> daven@lll-crg.llnl.gov (Dave Nelson) writes:
>Could someone tell me why prolog has no built-in macro facility?
>Even the industrial strength, full-featured prolog I am currently
>evaluating doesn't have such a thing.
>
>This sort of source-to-source transformation of files, *which can then
>be compiled*, is the LISP feature I miss the most (so far :-).

I've never heard of a real macro facility in any Prolog, but
the Prolog system I use (Quintus Prolog 2.2, which is about as
"industrial strength" as they come) has a built-in predicate called
expand_term/2 (which calls the user-defined predicate term_expansion/2)
which can be used as a preprocessor to do source-to-source transformation.
This is, in fact, how Prolog DCGs are translated into vanilla Prolog.

>Oh, and another thing...would it be so hard to put in a compile(pred, arity)
>to take a currently interpreted predicate and compile it?  All the
>compile(frob) directives interpret frob as a filename.

In Quintus Prolog, there's no built-in predicate like that,
but the Emacs-based development environment allows incremental
or piecemeal compiling (and consulting) of files.
So, for example, if you have a file all of whose predicates are
currently interpreted, but you want to compile foo/1 and bar/2
(but leave the rest of the predicates interpreted, that's very
easy to do.

----------------------------------------------------------------------------
Francois-Michel Lang
Paoli Research Center, Unisys Corporation lang@prc.unisys.com (215) 648-7256
Dept of Comp & Info Science, U of PA      lang@cis.upenn.edu  (215) 898-9511