Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 1460

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>1.2 Macro Module</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="node2.html#section.call.and.define">&lt;&lt; Prev</A></TD><TD><A href="node1.html">- Up -</A></TD><TD><A href="node4.html#section.backquote.macro">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.macro.module"><H2><A name="section.macro.module">1.2 <CODE>Macro</CODE> Module</A></H2><P></P><DL><DT><CODE>macroExpand</CODE></DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>{Macro<SPAN class="keyword">.</SPAN>macroExpand&nbsp;</CODE><CODE>+<I>X</I></CODE><CODE>&nbsp;</CODE><CODE>+<I>Env</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>Y</I></CODE><CODE>}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DD><DD><P><CODE>X</CODE> is a term representing Oz code using <EM>Syntax Tree Format</EM>. This performs full macro expansion on <CODE>X</CODE> with respect to macro environment <CODE>Env</CODE> and returns <CODE>Y</CODE> which is guaranteed to no longer contain any macro invocation. A macro environment maps macro names to expanders. <CODE>Env</CODE> may also be <CODE><SPAN class="keyword">unit</SPAN></CODE> in which case the global macro environment is used which contains all the macros registered using <CODE>Macro<SPAN class="keyword">.</SPAN>defmacro</CODE>.</P></DD><DT><CODE>defmacro</CODE></DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>{Macro<SPAN class="keyword">.</SPAN>defmacro&nbsp;</CODE><CODE>+<I>A</I></CODE><CODE>&nbsp;</CODE><CODE>+<I>F</I></CODE><CODE>}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DD><DD><P><CODE>A</CODE> should be an atom. A new global macro is defined which is invoked using atom <CODE>A</CODE> and implemented using macro expander <CODE>F</CODE>.</P></DD><DT><CODE>makeVar</CODE></DT><DT><CODE>makeNamedVar</CODE></DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>{Macro<SPAN class="keyword">.</SPAN>makeVar&nbsp;</CODE><CODE>?<I>X</I></CODE><CODE>}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DD><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>{Macro<SPAN class="keyword">.</SPAN>makeNamedVar&nbsp;</CODE><CODE>+<I>A</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>X</I></CODE><CODE>}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DD><DD><P>This is very useful to create on the fly new representations of variables that are guaranteed not to conflict with those in user code. With <CODE>Macro<SPAN class="keyword">.</SPAN>makeNamedVar</CODE>, you supply an atom that provides the variable with a more meaningful name. This can be helpful for debugging. For example: </P><BLOCKQUOTE class="code"><CODE>X&nbsp;=&nbsp;{Macro<SPAN class="keyword">.</SPAN>makeNamedVar&nbsp;<SPAN class="string">'Tail'</SPAN>}</CODE></BLOCKQUOTE><P> creates a new variable representation, guaranteed to be distinct from any other variable representation, and whose print name is <CODE>Tail</CODE>.</P></DD><DT><CODE>sequenceToList</CODE></DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>{Macro<SPAN class="keyword">.</SPAN>sequenceToList&nbsp;</CODE><CODE>+<I>X</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>L</I></CODE><CODE>}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DD><DD><P>Converts the syntactic representation of a sequence to a list</P></DD><DT><CODE>listToSequence</CODE></DT><DD><BLOCKQUOTE class="synopsis"><P></P><BLOCKQUOTE class="code"><CODE>{Macro<SPAN class="keyword">.</SPAN>listToSequence&nbsp;</CODE><CODE>+<I>L</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>X</I></CODE><CODE>}</CODE></BLOCKQUOTE><P></P></BLOCKQUOTE></DD><DD><P>Converts a list to the syntactic representation of a sequence</P></DD></DL><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node2.html#section.call.and.define">&lt;&lt; Prev</A></TD><TD><A href="node1.html">- Up -</A></TD><TD><A href="node4.html#section.backquote.macro">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys&nbsp;Duchier</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>