Article View: comp.lang.prolog
Article #3479Re: Why no macro facility?
From: John Dowding
Date: Tue, 12 Jul 1988 18:35
Date: Tue, 12 Jul 1988 18:35
37 lines
1473 bytes
1473 bytes
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.
>
>daven (Dave Nelson)
>
I did some experiements with this kind of thing with a parser and found that
it slowed the program down. I think that this is because current Prolog compilers
dont handle very large clauses well. Consider this example:
p(X):-
q(X),
r(X),
s(Y).
q(tree(_,_,_,_)).
If we turn q into a macro, then the resulting clause for p is:
p(tree(A,B,C,D)):-
r(tree(A,B,C,D)),
s(tree(A,B,C,D)).
Note also that where there use to be a single variable X that pointed to the
structure tree/4, now there isnt.
In my application, the use of macros made the size of the resulting clauses enormous.
The resulting program ran as much as 2 times slower than the version with
procedure calls.
John Dowding
dowding@prc.unisys.com
Technical Details
Message-ID:
<6899@burdvax.PRC.Unisys.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bbn!rochester!udel!burdvax!macbeth!dowdingReferences:
<9671@lll-winken.llnl.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bbn!rochester!udel!burdvax!macbeth!dowding From: dowding@macbeth.PRC.Unisys.COM (John Dowding) Newsgroups: comp.lang.prolog Subject: Re: Why no macro facility? Message-ID: <6899@burdvax.PRC.Unisys.COM> Date: 12 Jul 88 18:35:31 GMT References: <9671@lll-winken.llnl.gov> Sender: news@PRC.Unisys.COM Organization: Unisys Corporation, Paoli Research Center; Paoli, PA Lines: 37