/usr/share/mozart/doc/macro/node1.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>1 Macro Facility</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="index.html">- Up -</A></TD><TD><A href="node5.html#chapter.loop">Next >></A></TD></TR></TABLE><DIV id="chapter.macro"><H1><A name="chapter.macro">1 Macro Facility</A></H1><P>A new macro facility has now been integrated into the Mozart system. This is <EM>not</EM> a preprocessing facility: preprocessors such as <SPAN class="name">CPP</SPAN> or <SPAN class="name">M4</SPAN> are widely available and can be used for preprocessing arbitrary files. You could easily use them to preprocess files of Oz code. This is not what we discuss here. The Mozart macro facility is closer in spirit to that of Lisp.</P><HR><UL class="toc"><LI><A href="node2.html#section.call.and.define">1.1 Invoking And Defining Macros</A></LI></UL><UL class="toc"><LI><A href="node3.html#section.macro.module">1.2 <CODE>Macro</CODE> Module</A></LI></UL><UL class="toc"><LI><A href="node4.html#section.backquote.macro">1.3 Backquote Macro</A></LI></UL><HR><H2><A name="label1">1.4 Compiling functors that use macros</A></H2><P>It doesn't work to write a functor that both defines macros and uses them: when the functor is being compiled the macros have not yet been defined. The trick is to take advantage of compiler options <CODE>--include</CODE> or <CODE>--environment</CODE> to get the compiler to execute code defining your macros before going on to compile your functor. We now describe how to achieve the desired effect using option <CODE>--environment</CODE>.</P><P>First we create a functor that defines new macros. It exports nothing, but just registers the macros. Suppose we write file <CODE>unless.oz</CODE> containing: </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">functor</SPAN> <BR><SPAN class="keyword">import</SPAN> Macro<BR><SPAN class="keyword">define</SPAN> <BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">UnlessExpander</SPAN> fMacro(M<SPAN class="keyword">|</SPAN>B<SPAN class="keyword">|</SPAN>L C) Env}<BR> fBoolCase(<BR> B<BR> fSkip(<SPAN class="keyword">unit</SPAN>)<BR> {Macro<SPAN class="keyword">.</SPAN>listToSequence L}<BR> C)<BR> <SPAN class="keyword">end</SPAN> <BR> {Macro<SPAN class="keyword">.</SPAN>defmacro unless UnlessExpander}<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P> We compile it as usual: </P><BLOCKQUOTE class="code"><CODE>ozc -c unless.oz</CODE></BLOCKQUOTE><P> Now we write file <CODE>do.oz</CODE> that makes use of this macro: </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">functor</SPAN> <BR><SPAN class="keyword">import</SPAN> System(show:Show)<BR><SPAN class="keyword">export</SPAN> Do<BR><SPAN class="keyword">define</SPAN> <BR> <SPAN class="keyword">proc</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">Do</SPAN> X Y}<BR> <SPAN class="keyword"><<</SPAN>unless X<SPAN class="keyword"><</SPAN>Y {Show X} {Show Y}<SPAN class="keyword">>></SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P> The trick is to compile it as follows: </P><BLOCKQUOTE class="code"><CODE>ozc -l <SPAN class="string">'Bogus=unless.ozf'</SPAN> -c do.oz</CODE></BLOCKQUOTE><P> When the compiler processes option <CODE>-l</CODE> it links in the new module <CODE>Bogus</CODE> using functor <CODE>unless.ozf</CODE>. Module <CODE>Bogus</CODE> is in itself uninteresting; only the side-effects resulting from linking it are really what we are after, namely to define and register new macros.</P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="index.html">- Up -</A></TD><TD><A href="node5.html#chapter.loop">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|