Sophie

Sophie

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>9.8 Classes</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="lock.html#section.chunks.locks">&lt;&lt; Prev</A></TD><TD><A href="node11.html">- Up -</A></TD><TD><A href="object.html#section.chunks.objects">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="section.chunks.classes"><H2><A name="section.chunks.classes">9.8 Classes</A></H2><P> The module <A name="label649"></A><SPAN class="index"><CODE>Class</CODE></SPAN> contains procedures operating on classes. </P><DL><DT><A name="label650"></A><SPAN class="index"><CODE>IsClass</CODE></SPAN> <A name="label652"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Class<SPAN class="keyword">.</SPAN>is&nbsp;</CODE><CODE>+<I>X</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>B</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>tests whether <CODE><I>X</I></CODE> is a class. </P></DD><DT><CODE>new</CODE> <A name="label654"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Class<SPAN class="keyword">.</SPAN>new&nbsp;</CODE><CODE>+<I>ParentKs</I></CODE><CODE>&nbsp;</CODE><CODE>+<I>AttrR</I></CODE><CODE>&nbsp;</CODE><CODE>+<I>FeatR</I></CODE><CODE>&nbsp;</CODE><CODE>+<I>PropAs</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>K</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>creates a new class by inheriting from <CODE><I>ParentKs</I></CODE> with new attributes <CODE><I>AttrR</I></CODE> and new features <CODE><I>FeatR</I></CODE>. The fields with integer features in <CODE><I>AttrR</I></CODE> define the free attributes. The fields with literal features define attributes with initial values, where the feature is the attribute name and the field its initial value. The semantics for <CODE><I>FeatR</I></CODE> is accordingly. The properties of the class to be created are defined by <CODE><I>PropAs</I></CODE> (a list of atoms, valid elements are <CODE>sited</CODE>, <CODE>final</CODE>, and <CODE>locking</CODE>). </P><P> For example, the statement </P><BLOCKQUOTE class="code"><CODE>C={Class<SPAN class="keyword">.</SPAN>new&nbsp;[D&nbsp;E]&nbsp;a(a:1&nbsp;b)&nbsp;f(f:2&nbsp;g)&nbsp;[final]}</CODE></BLOCKQUOTE><P> is equivalent to </P><BLOCKQUOTE class="code"><CODE><SPAN class="keyword">class</SPAN>&nbsp;<SPAN class="type">C</SPAN>&nbsp;<SPAN class="keyword">from</SPAN><SPAN class="type">&nbsp;D&nbsp;E</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">prop</SPAN>&nbsp;final<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">attr</SPAN>&nbsp;a:1&nbsp;b<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">feat</SPAN>&nbsp;f:2&nbsp;g<BR><SPAN class="keyword">end</SPAN></CODE></BLOCKQUOTE><P> </P></DD><DT><CODE>getAttr</CODE> <A name="label656"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Class<SPAN class="keyword">.</SPAN>getAttr&nbsp;</CODE><CODE>+<I>K</I></CODE><CODE>&nbsp;</CODE><CODE>+<I>LI</I></CODE><CODE>&nbsp;</CODE><CODE>?<I>X</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>Returns the initival value <CODE><I>X</I></CODE> for attribute <CODE><I>LI</I></CODE> as defined by the class <CODE><I>K</I></CODE>. </P><P> For example, the statement </P><BLOCKQUOTE class="code"><CODE>{Class<SPAN class="keyword">.</SPAN>getAttr&nbsp;<SPAN class="keyword">class</SPAN>&nbsp;<SPAN class="keyword">attr</SPAN>&nbsp;a:4&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;a}</CODE></BLOCKQUOTE><P> returns <CODE>4</CODE>. </P></DD></DL><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="lock.html#section.chunks.locks">&lt;&lt; Prev</A></TD><TD><A href="node11.html">- Up -</A></TD><TD><A href="object.html#section.chunks.objects">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys&nbsp;Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif&nbsp;Kornstaedt</A> and&nbsp;<A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>