Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > d07d7ab417d79053e7e0155c99e1a1c8 > files > 2356

mlton-20100608-3.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta name="robots" content="index,nofollow">



<title>ObjectOrientedProgramming - MLton Standard ML Compiler (SML Compiler)</title>
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="all" href="common.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="screen.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="print" href="print.css">


<link rel="Start" href="Home">


</head>

<body lang="en" dir="ltr">

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-833377-1";
urchinTracker();
</script>
<table bgcolor = lightblue cellspacing = 0 style = "border: 0px;" width = 100%>
  <tr>
    <td style = "
		border: 0px;
		color: darkblue; 
		font-size: 150%;
		text-align: left;">
      <a class = mltona href="Home">MLton MLTONWIKIVERSION</a>
    <td style = "
		border: 0px;
		font-size: 150%;
		text-align: center;
		width: 50%;">
      ObjectOrientedProgramming
    <td style = "
		border: 0px;
		text-align: right;">
      <table cellspacing = 0 style = "border: 0px">
        <tr style = "vertical-align: middle;">
      </table>
  <tr style = "background-color: white;">
    <td colspan = 3
	style = "
		border: 0px;
		font-size:70%;
		text-align: right;">
      <a href = "Home">Home</a>
      &nbsp;<a href = "TitleIndex">Index</a>
      &nbsp;
</table>
<div id="content" lang="en" dir="ltr">
<a href="StandardML">Standard ML</a> does not have explicit support for object-oriented programming.  Here are some papers that show how to express certain object-oriented concepts in SML. 
    <ul>

    <li>
<p>
 <a href = "References#Berthomieu00"> OO Programming styles in ML</a> 
</p>
</li>
    <li class="gap">
<p>
 <a href = "References#ThorupTofte94"> Object-oriented programming and Standard ML</a> 
</p>
</li>
    <li class="gap">
<p>
 <a href = "References#LarsenNiss04"> mGTK: An SML binding of Gtk+</a> 
</p>
</li>
    <li class="gap">
<p>
 <a href = "References#FluetPucella02"> Phantom Types and Subtyping</a> 
</p>
</li>

    </ul>


<hr>
 <p>
The question of OO programming in SML comes up every now and then.  The following discusses a simple object-oriented (OO) programming technique in Standard ML.  The reader is assumed to be able to read Java and SML code. 
</p>
<h3 id="head-d6a06199cc127e571d3588aef63c79108675eabc">Motivation</h3>
<p>
SML doesn't provide subtyping, but it does provide parametric polymorphism, which can be used to encode some forms of subtyping.  Most articles on OO programming in SML concentrate on such encoding techniques. While those techniques are interesting --- and it is recommended to read such articles --- and sometimes useful, it seems that basically all OO gurus agree that (deep) subtyping (or inheritance) hierarchies aren't as practical as they were thought to be in the early OO days.  "Good", flexible, "OO" designs tend to have a flat structure 
</p>

<pre>         Interface
             ^
             |
- - -+-------+-------+- - -
     |       |       |
   ImplA   ImplB   ImplC
</pre><p>
and deep inheritance hierarchies 
</p>

<pre>ClassA
  ^
  |
ClassB
  ^
  |
ClassC
  ^
  |
</pre><p>
tend to be signs of design mistakes.  There are good underlying reasons for this, but a thorough discussion is not in the scope of this article. However, the point is that perhaps the encoding of subtyping is not as important as one might believe.  In the following we ignore subtyping and rather concentrate on a very simple and basic dynamic dispatch technique. 
</p>
<h3 id="head-af906b64b88d8a14633674631d41c471e32ab7ce">Dynamic Dispatch Using a Recursive Record of Functions</h3>
<p>
Quite simply, the basic idea is to implement a "virtual function table" using a record that is wrapped inside a (possibly recursive) datatype. Let's first take a look at a simple concrete example. 
</p>
<p>
Consider the following Java interface: 
</p>

<pre>public interface Counter {
  public void inc();
  public int get();
}
</pre><p>
We can translate the Counter interface to SML as follows: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> counter </FONT></B>=<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">Counter</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> {inc : unit -&gt; unit, get : unit -&gt; int}
</FONT></B></PRE>
<p>
 
</p>
<p>
Each value of type <tt>counter</tt> can be thought of as an object that responds to two messages <tt>inc</tt> and <tt>get</tt>.  To actually send messages to a counter, it is useful to define auxiliary functions 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">local</FONT></B>
   <B><FONT COLOR="#A020F0">fun</FONT></B> mk m (Counter t) = m t ()
<B><FONT COLOR="#0000FF">in</FONT></B>
   <B><FONT COLOR="#A020F0">val</FONT></B> cGet = mk#get
   <B><FONT COLOR="#A020F0">val</FONT></B> cInc = mk#inc
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
that basically extract the "function table" <tt>t</tt> from a counter object and then select the specified method <tt>m</tt> from the table. 
</p>
<p>
Let's then implement a simple function that increments a counter until a given maximum is reached: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">fun</FONT></B> incUpto counter max = <B><FONT COLOR="#A020F0">while</FONT></B> cGet counter &lt; max <B><FONT COLOR="#A020F0">do</FONT></B> cInc counter
</PRE>
<p>
 
</p>
<p>
You can easily verify that the above code compiles even without any concrete implementation of a counter, thus it is clear that it doesn't depend on a particular counter implementation. 
</p>
<p>
Let's then implement a couple of counters.  First consider the following Java class implementing the Counter interface given earlier. 
</p>

<pre>public class BasicCounter implements Counter {
  private int cnt;
  public BasicCounter(int initialCnt) { this.cnt = initialCnt; }
  public void inc() { this.cnt += 1; }
  public int get() { return this.cnt; }
}
</pre><p>
We can translate the above to SML as follows: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">fun</FONT></B> newBasicCounter initialCnt = <B><FONT COLOR="#A020F0">let</FONT></B>
       <B><FONT COLOR="#A020F0">val</FONT></B> cnt = ref initialCnt
    <B><FONT COLOR="#A020F0">in</FONT></B>
       Counter {inc = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; cnt := !cnt + <B><FONT COLOR="#5F9EA0">1</FONT></B>,
                get = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; !cnt}
    <B><FONT COLOR="#A020F0">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
The SML function <tt>newBasicCounter</tt> can be described as a constructor function for counter objects of the <tt>BasicCounter</tt> "class".  We can also have other counter implementations.  Here is the constructor for a counter decorator that logs messages: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">fun</FONT></B> newLoggedCounter counter =
    Counter {inc = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; (print <B><FONT COLOR="#BC8F8F">&quot;inc\n&quot;</FONT></B> ; cInc counter),
             get = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; (print <B><FONT COLOR="#BC8F8F">&quot;get\n&quot;</FONT></B> ; cGet counter)}
</PRE>
<p>
 
</p>
<p>
The <tt>incUpto</tt> function works just as well with objects of either class: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">val</FONT></B> aCounter = newBasicCounter <B><FONT COLOR="#5F9EA0">0</FONT></B>
<B><FONT COLOR="#A020F0">val</FONT></B> () = incUpto aCounter <B><FONT COLOR="#5F9EA0">5</FONT></B>
<B><FONT COLOR="#A020F0">val</FONT></B> () = print (Int.toString (cGet aCounter) ^<B><FONT COLOR="#BC8F8F">&quot;\n&quot;</FONT></B>)

<B><FONT COLOR="#A020F0">val</FONT></B> aCounter = newLoggedCounter (newBasicCounter <B><FONT COLOR="#5F9EA0">0</FONT></B>)
<B><FONT COLOR="#A020F0">val</FONT></B> () = incUpto aCounter <B><FONT COLOR="#5F9EA0">5</FONT></B>
<B><FONT COLOR="#A020F0">val</FONT></B> () = print (Int.toString (cGet aCounter) ^<B><FONT COLOR="#BC8F8F">&quot;\n&quot;</FONT></B>)
</PRE>
<p>
 
</p>
<p>
In general, a dynamic dispatch interface is represented as a record type wrapped inside a datatype.  Each field of the record corresponds to a public method or field of the object: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> interface </FONT></B>=<B><FONT COLOR="#228B22">
   <FONT COLOR="#B8860B">Interface</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> {method : t1 -&gt; t2,
                 immutableField : t,
                 mutableField : t ref}
</FONT></B></PRE>
<p>
 
</p>
<p>
The reason for wrapping the record inside a datatype is that records, in SML, can not be recursive.  However, SML datatypes can be recursive.  A record wrapped in a datatype can contain fields that contain the datatype. For example, an interface such as Cloneable 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> cloneable </FONT></B>=<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">Cloneable</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> {clone : unit -&gt; cloneable}
</FONT></B></PRE>
<p>
 
</p>
<p>
can be represented using recursive datatypes. 
</p>
<p>
Like in OO languages, interfaces are abstract and can not be instantiated to produce objects.  To be able to instantiate objects, the constructors of a concrete class are needed.  In SML, we can implement constructors as simple functions from arbitrary arguments to values of the interface type. Such a constructor function can encapsulate arbitrary private state and functions using lexical closure.  It is also easy to share implementations of methods between two or more constructors. 
</p>
<p>
While the <tt>Counter</tt> example is rather trivial, it should not be difficult to see that this technique quite simply doesn't require a huge amount of extra verbiage and is more than usable in practice. 
</p>
<h3 id="head-343f19d7557070bf1d1603ce9f1f8c2f1220bd70">SML Modules and Dynamic Dispatch</h3>
<p>
One might wonder about how SML modules and the dynamic dispatch technique work together.  Let's investigate!  Let's use a simple dispenser framework as a concrete example.  (Note that this isn't intended to be an introduction to the SML module system.) 
</p>
<h4 id="head-8657a6eb69095e43b608460695dc355aaf3781a7">Programming with SML Modules</h4>
<p>
Using SML signatures we can specify abstract data types (ADTs) such as dispensers.  Here is a signature for an "abstract" functional (as opposed to imperative) dispenser: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> ABSTRACT_DISPENSER = <B><FONT COLOR="#0000FF">sig</FONT></B>
   <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> 'a t
   </FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> isEmpty : 'a t -&gt; bool
   <B><FONT COLOR="#A020F0">val</FONT></B> push : 'a * 'a t -&gt; 'a t
   <B><FONT COLOR="#A020F0">val</FONT></B> pop : 'a t -&gt; ('a * 'a t) option
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
The term "abstract" in the name of the signature refers to the fact that the signature gives no way to instantiate a dispenser.  It has nothing to do with the concept of abstract data types. 
</p>
<p>
Using SML functors we can write "generic" algorithms that manipulate dispensers of an unknown type.  Here are a couple of very simple algorithms: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">functor</FONT></B> DispenserAlgs (D : ABSTRACT_DISPENSER) = <B><FONT COLOR="#0000FF">struct</FONT></B>
   <B><FONT COLOR="#0000FF">open</FONT></B> D

   <B><FONT COLOR="#A020F0">fun</FONT></B> pushAll (xs, d) = foldl push d xs

   <B><FONT COLOR="#A020F0">fun</FONT></B> popAll d = <B><FONT COLOR="#A020F0">let</FONT></B>
          <B><FONT COLOR="#A020F0">fun</FONT></B> lp (xs, NONE) = rev xs
            | lp (xs, SOME (x, d)) = lp (x::xs, pop d)
       <B><FONT COLOR="#A020F0">in</FONT></B>
          lp ([], pop d)
       <B><FONT COLOR="#A020F0">end</FONT></B>

   <B><FONT COLOR="#A020F0">fun</FONT></B> cp (from, to) = pushAll (popAll from, to)
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
As one can easily verify, the above compiles even without any concrete dispenser structure.  Functors essentially provide a form a static dispatch that one can use to break compile-time dependencies. 
</p>
<p>
We can also give a signature for a concrete dispenser 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">signature</FONT></B> DISPENSER = <B><FONT COLOR="#0000FF">sig</FONT></B>
   <B><FONT COLOR="#0000FF">include</FONT></B> ABSTRACT_DISPENSER
   <B><FONT COLOR="#A020F0">val</FONT></B> empty : 'a t
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
and write any number of concrete structures implementing the signature. For example, we could implement stacks 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> Stack :&gt; DISPENSER = <B><FONT COLOR="#0000FF">struct</FONT></B>
   <B><FONT COLOR="#A020F0">type</FONT></B><B><FONT COLOR="#228B22"> 'a t </FONT></B>=<B><FONT COLOR="#228B22"> 'a list
   </FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> empty = []
   <B><FONT COLOR="#A020F0">val</FONT></B> isEmpty = null
   <B><FONT COLOR="#A020F0">val</FONT></B> push = <B><FONT COLOR="#A020F0">op</FONT></B> ::
   <B><FONT COLOR="#A020F0">val</FONT></B> pop = List.getItem
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
and queues 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> Queue :&gt; DISPENSER = <B><FONT COLOR="#0000FF">struct</FONT></B>
   <B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> 'a t </FONT></B>=<B><FONT COLOR="#228B22"> <FONT COLOR="#B8860B">T</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> 'a list * 'a list
   </FONT></B><B><FONT COLOR="#A020F0">val</FONT></B> empty = T ([], [])
   <B><FONT COLOR="#A020F0">val</FONT></B> isEmpty = <B><FONT COLOR="#A020F0">fn</FONT></B> T ([], _) =&gt; true | _ =&gt; false
   <B><FONT COLOR="#A020F0">val</FONT></B> normalize = <B><FONT COLOR="#A020F0">fn</FONT></B> ([], ys) =&gt; (rev ys, []) | q =&gt; q
   <B><FONT COLOR="#A020F0">fun</FONT></B> push (y, T (xs, ys)) = T (normalize (xs, y::ys))
   <B><FONT COLOR="#A020F0">val</FONT></B> pop = <B><FONT COLOR="#A020F0">fn</FONT></B> (T (x::xs, ys)) =&gt; SOME (x, T (normalize (xs, ys))) | _ =&gt; NONE
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
One can now write code that uses either the <tt>Stack</tt> or the <tt>Queue</tt> dispenser.  One can also instantiate the previously defined functor to create functions for manipulating dispensers of a type: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> S = DispenserAlgs (Stack)
<B><FONT COLOR="#A020F0">val</FONT></B> [<B><FONT COLOR="#5F9EA0">4</FONT></B>,<B><FONT COLOR="#5F9EA0">3</FONT></B>,<B><FONT COLOR="#5F9EA0">2</FONT></B>,<B><FONT COLOR="#5F9EA0">1</FONT></B>] = S.popAll (S.pushAll ([<B><FONT COLOR="#5F9EA0">1</FONT></B>,<B><FONT COLOR="#5F9EA0">2</FONT></B>,<B><FONT COLOR="#5F9EA0">3</FONT></B>,<B><FONT COLOR="#5F9EA0">4</FONT></B>], Stack.empty))

<B><FONT COLOR="#0000FF">structure</FONT></B> Q = DispenserAlgs (Queue)
<B><FONT COLOR="#A020F0">val</FONT></B> [<B><FONT COLOR="#5F9EA0">1</FONT></B>,<B><FONT COLOR="#5F9EA0">2</FONT></B>,<B><FONT COLOR="#5F9EA0">3</FONT></B>,<B><FONT COLOR="#5F9EA0">4</FONT></B>] = Q.popAll (Q.pushAll ([<B><FONT COLOR="#5F9EA0">1</FONT></B>,<B><FONT COLOR="#5F9EA0">2</FONT></B>,<B><FONT COLOR="#5F9EA0">3</FONT></B>,<B><FONT COLOR="#5F9EA0">4</FONT></B>], Queue.empty))
</PRE>
<p>
 
</p>
<p>
There is no dynamic dispatch involved at the module level in SML.  An attempt to do dynamic dispatch 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">val</FONT></B> q = Q.push (<B><FONT COLOR="#5F9EA0">1</FONT></B>, Stack.empty)
</PRE>
<p>
 
</p>
<p>
will give a type error. 
</p>
<h4 id="head-32ba757ff59bb9cc712ae2effacaf072778872d7">Combining SML Modules and Dynamic Dispatch</h4>
<p>
Let's then combine SML modules and the dynamic dispatch technique introduced in this article.  First we define an interface for dispensers: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> Dispenser = <B><FONT COLOR="#0000FF">struct</FONT></B>
   <B><FONT COLOR="#A020F0">datatype</FONT></B><B><FONT COLOR="#228B22"> 'a t </FONT></B>=<B><FONT COLOR="#228B22">
      <FONT COLOR="#B8860B">I</FONT> <B><FONT COLOR="#A020F0">of</FONT></B> {isEmpty : unit -&gt; bool,
            push : 'a -&gt; 'a t,
            pop : unit -&gt; ('a * 'a t) option}

   </FONT></B><B><FONT COLOR="#A020F0">fun</FONT></B> O m (I t) = m t

   <B><FONT COLOR="#A020F0">fun</FONT></B> isEmpty t = O#isEmpty t ()
   <B><FONT COLOR="#A020F0">fun</FONT></B> push (v, t) = O#push t v
   <B><FONT COLOR="#A020F0">fun</FONT></B> pop t = O#pop t ()
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
The <tt>Dispenser</tt> module, which we can think of as an interface for dispensers, implements the <tt>ABSTRACT_DISPENSER</tt> signature using the dynamic dispatch technique, but we leave the signature ascription until later. 
</p>
<p>
Then we define a <tt>DispenserClass</tt> functor that makes a "class" out of a given dispenser module: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">functor</FONT></B> DispenserClass (D : DISPENSER) : DISPENSER = <B><FONT COLOR="#0000FF">struct</FONT></B>
   <B><FONT COLOR="#0000FF">open</FONT></B> Dispenser

   <B><FONT COLOR="#A020F0">fun</FONT></B> make d =
       I {isEmpty = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; D.isEmpty d,
          push = <B><FONT COLOR="#A020F0">fn</FONT></B> x =&gt; make (D.push (x, d)),
          pop = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt;
                   <B><FONT COLOR="#A020F0">case</FONT></B> D.pop d <B><FONT COLOR="#A020F0">of</FONT></B>
                      NONE =&gt; NONE
                    | SOME (x, d) =&gt; SOME (x, make d)}

   <B><FONT COLOR="#A020F0">val</FONT></B> empty =
       I {isEmpty = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; true,
          push = <B><FONT COLOR="#A020F0">fn</FONT></B> x =&gt; make (D.push (x, D.empty)),
          pop = <B><FONT COLOR="#A020F0">fn</FONT></B> () =&gt; NONE}
<B><FONT COLOR="#0000FF">end</FONT></B>
</PRE>
<p>
 
</p>
<p>
Finally we seal the <tt>Dispenser</tt> module: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> Dispenser : ABSTRACT_DISPENSER = Dispenser
</PRE>
<p>
 
</p>
<p>
This isn't necessary for type safety, because the unsealed <tt>Dispenser</tt> module does not allow one to break encapsulation, but makes sure that only the <tt>DispenserClass</tt> functor can create dispenser classes (because the constructor <tt>Dispenser.I</tt> is no longer accessible). 
</p>
<p>
Using the <tt>DispenserClass</tt> functor we can turn any concrete dispenser module into a dispenser class: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> StackClass = DispenserClass (Stack)
<B><FONT COLOR="#0000FF">structure</FONT></B> QueueClass = DispenserClass (Queue)
</PRE>
<p>
 
</p>
<p>
Each dispenser class implements the same dynamic dispatch interface and the <tt>ABSTRACT_DISPENSER</tt> -signature. 
</p>
<p>
Because the dynamic dispatch <tt>Dispenser</tt> module implements the <tt>ABSTRACT_DISPENSER</tt> -signature, we can use it to instantiate the <tt>DispenserAlgs</tt> -functor: 
</p>

<pre class=code>
<B><FONT COLOR="#0000FF">structure</FONT></B> D = DispenserAlgs (Dispenser)
</PRE>
<p>
 
</p>
<p>
The resulting <tt>D</tt> module, like the <tt>Dispenser</tt> module, works with any dispenser class and uses dynamic dispatch: 
</p>

<pre class=code>
<B><FONT COLOR="#A020F0">val</FONT></B> [<B><FONT COLOR="#5F9EA0">4</FONT></B>, <B><FONT COLOR="#5F9EA0">3</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <B><FONT COLOR="#5F9EA0">1</FONT></B>] = D.popAll (D.pushAll ([<B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <B><FONT COLOR="#5F9EA0">3</FONT></B>, <B><FONT COLOR="#5F9EA0">4</FONT></B>], StackClass.empty))
<B><FONT COLOR="#A020F0">val</FONT></B> [<B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <B><FONT COLOR="#5F9EA0">3</FONT></B>, <B><FONT COLOR="#5F9EA0">4</FONT></B>] = D.popAll (D.pushAll ([<B><FONT COLOR="#5F9EA0">1</FONT></B>, <B><FONT COLOR="#5F9EA0">2</FONT></B>, <B><FONT COLOR="#5F9EA0">3</FONT></B>, <B><FONT COLOR="#5F9EA0">4</FONT></B>], QueueClass.empty))
</PRE>
<p>
 
</p>
</div>



<p>
<hr>
Last edited on 2008-10-20 11:18:45 by <span title="otaku.housemarque.fi"><a href="VesaKarvonen">VesaKarvonen</a></span>.
</body></html>