rev 501 - in trunk: docs/tutorial pr/tutorial

SVN User <[email protected]> Tue, 18 May 2004 15:06:25 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-05-18 15:06:22 -0400 (Tue, 18 May 2004)
New Revision: 501

Added:
   trunk/pr/tutorial/tut12.pr
Modified:
   trunk/docs/tutorial/index2.htm
   trunk/docs/tutorial/tutorial8.htm
   trunk/docs/tutorial/tutorial9.htm
Log:
added multiple inheritance to tutorial

Modified: trunk/docs/tutorial/index2.htm
===================================================================
--- trunk/docs/tutorial/index2.htm	2004-05-18 06:47:42 UTC (rev 500)
+++ trunk/docs/tutorial/index2.htm	2004-05-18 19:06:22 UTC (rev 501)
@@ -38,13 +38,59 @@
     <tr> 
       <td height="2203" valign="top"> 
         <ul>
-          <li>6. <a href="tutorial8.htm#myoo">Prototype-based Programming</a> 
+          <li>6. <a href="tutorial8.htm#pbp">Prototype-based Programming</a> 
             <ul>
-              <li><a href="tutorial8.htm#oaok">6.1 Making Your Own Object</a> 
+              <li><a href="tutorial8.htm#myoo">6.1 Making Your Own Object</a> 
                 <ul>
-                  <li><a href="tutorial8.htm#oeof">obj = Object()</a>
+                  <li><a href="tutorial8.htm#oeof">obj = Object()</a> 
+                  <li><a href="tutorial8.htm#objid">Object ID</a> 
+                  <li><a href="tutorial8.htm#addattr">Adding Attributes</a> 
+                  <li><a href="tutorial8.htm#usingwith">Using With Statement</a> 
+                  <li><a href="tutorial8.htm#objectcentric">Object-centric Programming</a> 
+                  <li><a href="tutorial8.htm#copying">Object Copying</a> 
+                  <li><a href="tutorial8.htm#protypes">Prototypes</a> 
+                  <li><a href="tutorial8.htm#anyobj">Any Object Can Be A Proto</a> 
                 </ul>
-              
+              <li><a href="tutorial8.htm#ppl">6.2 Parent Prototype Links</a> 
+                <ul>
+                  <li><a href="tutorial8.htm#copydis">Disadvantages of Copying</a> 
+                  <li><a href="tutorial8.htm#protolinks">Prototype Links</a> 
+                  <li><a href="tutorial8.htm#attrlookup">Attribute Searching</a> 
+                  <li><a href="tutorial8.htm#addattr">Special Object</a> 
+                  <li><a href="tutorial8.htm#attrlookexam">Attribute Lookup Example</a> 
+                  <li><a href="tutorial8.htm#inheritance">Inheritance</a> 
+                  <li><a href="tutorial8.htm#efficiency">Efficiency</a> 
+                </ul>
+              <li><a href="tutorial8.htm#objstmt">6.3 Object Statement</a> 
+                <ul>
+                  <li><a href="tutorial8.htm#objstmtex">Example</a> 
+                  <li><a href="tutorial8.htm#objform">Statement Format</a> 
+                </ul>
+              <li><a href="tutorial9.htm#init">6.4 Object Initialization</a> 
+                <ul>
+                  <li><a href="tutorial9.htm#oepargs">obj = Prototype(args)</a> 
+                  <li><a href="tutorial9.htm#initbar">Example of init_() Method</a> 
+                </ul>
+              <li><a href="tutorial9.htm#subtypes">6.5 Sub-types</a> 
+                <ul>
+                  <li><a href="tutorial9.htm#narrow">Narrowing a Category</a> 
+                  <li><a href="tutorial9.htm#directcall">Directed init_() Call</a> 
+                  <li><a href="tutorial9.htm#selfcall">Explicit Self in Call</a> 
+                </ul>
+              <li><a href="tutorial9.htm#chgtypes">6.6 Changing Object Types</a> 
+                <ul>
+                  <li><a href="tutorial9.htm#oaok">Changing Either Direction</a> 
+                  <li><a href="tutorial9.htm#ctex">Example</a> 
+                  <li><a href="tutorial9.htm#reopen">Reopening an Object</a> 
+                  <li><a href="tutorial9.htm#setProto">setProto() Function</a> 
+                  <li><a href="tutorial9.htm#strf">str_() Method</a> 
+                </ul>
+              <li><a href="tutorial9.htm#mulinh">6.7 Multiple Inheritance</a> 
+                <ul>
+                  <li><a href="tutorial9.htm#miwarn">Dangers of Multiple Inheritance</a> 
+                  <li><a href="tutorial9.htm#miex">Example</a> 
+                  <li><a href="tutorial9.htm#mixin">Mix-In</a> 
+                </ul>
             </ul>
         </ul>
       </td>
Modified: trunk/docs/tutorial/tutorial8.htm
===================================================================
--- trunk/docs/tutorial/tutorial8.htm	2004-05-18 06:47:42 UTC (rev 500)
+++ trunk/docs/tutorial/tutorial8.htm	2004-05-18 19:06:22 UTC (rev 501)
@@ -33,9 +33,9 @@
   <table width="630" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffee" height="1707">
     <tr> 
       <td height="3212" valign="top"> 
-        <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="myoo"></a>6.0 
+        <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="pbp"></a>6.0 
           Prototype-based Programming</font></p>
-        <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a>6.1 
+        <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="myoo"></a>6.1 
           Making Your Own Object</font></p>
         <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oeof"></a></font>So 
           far you have created many objects using special creation methods built 
@@ -47,15 +47,17 @@
         <pre>>>> Rectangle = Object()
 &lt;Object:939f40&gt;
 >>></pre>
-        <p>Prothon displays the empty object by just showing it's address in memory 
-          in hexadecimal. This can be useful at times because the address of an 
-          object never changes for the life of the object. When you compare two 
-          objects using the &quot;a is b&quot; operator, Prothon just compares 
-          the addresses. </p>
-        <p>If we want the new Rectangle object to represent a real rectangle, 
-          we should give it a width and height. We can use attributes to do that. 
-          Let's also add a method (function that uses &quot;self&quot;, also in 
-          an attribute) that calculates it's area:</p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="objid"></a></font>Prothon 
+          displays the empty object by just showing it's address in memory in 
+          hexadecimal. This address is sometimes known as the object's ID. This 
+          can be useful at times because the address of an object never changes 
+          for the life of the object. When you compare two objects using the &quot;a 
+          is b&quot; operator, Prothon just compares the addresses. </p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="addattr"></a></font>If 
+          we want the new Rectangle object to represent a real rectangle, we should 
+          give it a width and height. We can use attributes to do that. Let's 
+          also add a method (function that uses &quot;self&quot;, also in an attribute) 
+          that calculates it's area:</p>
         <pre>>>> Rectangle.width = 10
 10
 >>> Rectangle.height = 10
@@ -64,8 +66,9 @@
 ...    return self.width * self.height
 ...
 >>></pre>
-        <p>We promised you earlier that the with statement would be useful. Here 
-          is our chance to use it. Let's redo that last example using the &quot;with&quot; 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="usingwith"></a></font>We 
+          promised you earlier that the with statement would be useful. Here is 
+          our chance to use it. Let's redo that last example using the &quot;with&quot; 
           statement. Let's also show the area method in action:</p>
         <pre>>>> with Rectangle:
 ...    width = 10
@@ -81,18 +84,20 @@
           and &quot;height&quot; and can calculate its own area by it's &quot;area&quot; 
           method that is also stored in an attribute called &quot;area&quot;. 
         </p>
-        <p>Those of you familiar with object-oriented programming might notice 
-          that this is very similar behaviour to an object instance from a class 
-          called &quot;Rectangle&quot;, yet we have not defined any class at all, 
-          we just created the object directly. This is much simpler and more direct. 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="objectcentric"></a></font>Those 
+          of you familiar with object-oriented programming might notice that this 
+          is very similar behaviour to an object instance from a class called 
+          &quot;Rectangle&quot;, yet we have not defined any class at all, we 
+          just created the object directly. This is much simpler and more direct. 
           This is called &quot;object-centric&quot; programming instead of &quot;object-oriented&quot; 
           programming even though it is obviously &quot;oriented&quot; towards 
           objects. It is just that all the books and courses have already been 
           written that say that object-oriented programming has classes and it's 
           a bit too late too argue with them.</p>
-        <p>At this point we might want a lot of Rectangles. We can always make 
-          a second one by copying it. This is how some languages, and the Self 
-          language in particular, makes more of a &quot;type&quot; of object:</p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="copying"></a></font>At 
+          this point we might want a lot of Rectangles. We can always make a second 
+          one by copying it. This is how some languages, and the Self language 
+          in particular, makes more of a &quot;type&quot; of object:</p>
         <pre>>>> rect2 = Rectangle.copy()
 >>> print rect2.area()
 100
@@ -107,23 +112,26 @@
           attributes and different areas that represent different rectangles. 
           At this point there is nothing stopping us from using a for loop to 
           make a thousand rectangles. </p>
-        <p>So we can make many instances of rectangles that are just like the 
-          first Rectangle. That is why we call the first one the prototype. It 
-          is not like the class in an object-oriented language. A class is just 
-          a blueprint for making objects. A prototype is a real, working instance 
-          of an object. You can make the prototype and test it before you use 
-          it to make other instances. Using prototypes instead of classes is what 
-          makes Prothon a prototype-based language instead of a class-based language.</p>
-        <p>So did I trick you and let you think you were just making an object 
-          when you were really making a prototype? No, in reality every object 
-          in Prothon can also be a prototype. You could copy &quot;rect2&quot; 
-          to make a &quot;rect3&quot; and use it just like you copied &quot;Rectangle&quot;. 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="protypes"></a></font>So 
+          we can make many instances of rectangles that are just like the first 
+          Rectangle. That is why we call the first one the prototype. It is not 
+          like the class in an object-oriented language. A class is just a blueprint 
+          for making objects. A prototype is a real, working instance of an object. 
+          You can make the prototype and test it before you use it to make other 
+          instances. Using prototypes instead of classes is what makes Prothon 
+          a prototype-based language instead of a class-based language.</p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="anyobj"></a></font>So 
+          did I trick you and let you think you were just making an object when 
+          you were really making a prototype? No, in reality every object in Prothon 
+          can also be a prototype. You could copy &quot;rect2&quot; to make a 
+          &quot;rect3&quot; and use it just like you copied &quot;Rectangle&quot;. 
           Later you will find out things that make certain objects better at being 
           prototypes than other objects, but Prothon is an equal opportunity employer. 
           Any object may apply to be a Prototype.</p>
-        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a>6.2 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="ppl"></a>6.2 
           Parent Prototype Links</font></p>
-        <p>You may have noticed that the instances created above by the copy commands 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="copydis"></a></font>You 
+          may have noticed that the instances created above by the copy commands 
           above have some disadvantages compared to object-oriented intances made 
           by classes. The biggest problem is storage efficiency. Each of one the 
           rectangle instance objects has its very own copy of the area method. 
@@ -132,21 +140,24 @@
           It would be nice to change the code in one place and have it change 
           for all rectangles. It would not be fun to change the code in a thousand 
           different area methods.</p>
-        <p>To solve that problem and to add many new features, Prothon has added 
-          a third feature to objects, after binary data and attributes. This is 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="protolinks"></a></font>To 
+          solve that problem and to add many new features, Prothon has added a 
+          third feature to objects, after binary data and attributes. This is 
           an ordered list of links to prototypes. Each object has at least one 
           reference (link) to an object that is its &quot;parent prototype&quot;. 
           There can be more than one but let's discuss the case of one for right 
           now.</p>
-        <p>The parent prototype is just an ordinary object. The parent prototype 
-          is used whenever the object is having an attribute looked up and the 
-          attribute is not found. In this case, the search for that attribute 
-          continues in the parent's attributes. If the attribute isn't found there, 
-          then it continues in the parent's parent (grandparent's) attributes. 
-          In other words, search for attributes goes up the chain of prototype 
-          objects linked together by the prototype links.</p>
-        <p>You might wonder what ends this prototype chain. There is a special 
-          object, cleverly named &quot;Object&quot;, that is the end of all prototype 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="attrlookup"></a></font>The 
+          parent prototype is just an ordinary object. The parent prototype is 
+          used whenever the object is having an attribute looked up and the attribute 
+          is not found. In this case, the search for that attribute continues 
+          in the parent's attributes. If the attribute isn't found there, then 
+          it continues in the parent's parent (grandparent's) attributes. In other 
+          words, search for attributes goes up the chain of prototype objects 
+          linked together by the prototype links.</p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="addattr"></a></font>You 
+          might wonder what ends this prototype chain. There is a special object, 
+          cleverly named &quot;Object&quot;, that is the end of all prototype 
           chains. It is the ultimate parent of all objects. The common way to 
           create an empty object is to give it one prototype link to Object. That 
           is what we did earlier when we said &quot;Rectangle = Object()&quot;. 
@@ -157,7 +168,8 @@
         <pre>>>> print Rectangle.protoList()
 [&lt;Object:93b100&gt;, &lt;Object:923020:Object: prototype base for all objects&gt;]
 >>></pre>
-        <p>So what good is attribute lookup in prototypes? Let's redo rect2 using 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="attrlookexam"></a></font>So 
+          what good is attribute lookup in prototypes? Let's redo rect2 using 
           a prototype link instead of doing a copy. The easiest way to create 
           an object that has a prototype link to another object is to use the 
           form &quot;obj = Prototype()&quot;. This looks exactly like a function 
@@ -180,8 +192,9 @@
           width, height, and area we got the same results as before. This is because 
           each of the attribute lookups, both for data and functions, failed on 
           rect2 so the lookup went to Rectangle where the lookup succeeded. </p>
-        <p>In the case of rect2.area() resolving to Rectangle.area(), this kind 
-          of method lookup reminds us a lot of the method inheritance in object-oriented 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="inheritance"></a></font>In 
+          the case of rect2.area() resolving to Rectangle.area(), this kind of 
+          method lookup reminds us a lot of the method inheritance in object-oriented 
           programming. So we sometimes say in Prothon that rect2 &quot;inherited&quot; 
           the method area from Rectangle. In Prothon, we also &quot;inherit&quot; 
           data since we lookup all attributes in the prototype parents. This is 
@@ -200,17 +213,19 @@
           prototype &quot;Rectangle&quot;. Also, if we were to change the code 
           of the method &quot;area&quot; in the &quot;Rectangle&quot; prototype, 
           then the behaviour would change in rect2 also. </p>
-        <p>You can see that we could make a thousand objects that each have a 
-          link to Rectangle and each object would only need to have the data that 
-          is unique to that object. Also, any of the objects could have a different 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="efficiency"></a></font>You 
+          can see that we could make a thousand objects that each have a link 
+          to Rectangle and each object would only need to have the data that is 
+          unique to that object. Also, any of the objects could have a different 
           area method for different behaviour if you wished. Prototype-based programming 
           is very flexible compared to class-based programming in addition to 
           being simpler.</p>
-        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a>6.3 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="objstmt"></a>6.3 
           Object Statement</font></p>
-        <p>There is a convenient statement, the &quot;Object&quot; statement, 
-          that combines the creation of the object and the with statement. The 
-          following replaces the first three code examples in this section 6:</p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="objstmtex"></a></font>There 
+          is a convenient statement, the &quot;Object&quot; statement, that combines 
+          the creation of the object and the with statement. The following replaces 
+          the first three code examples in this section 6:</p>
         <pre>>>> object Rectangle:
 ...    width = 10
 ...    height = 10
@@ -218,12 +233,14 @@
 ...       return self.width * self*height
 ...
 >>></pre>
-        <p>The general form of the Object statement is &quot;object name(prototypes): 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="objform"></a></font>The 
+          general form of the Object statement is &quot;object name(prototypes): 
           body&quot;. &quot;Name&quot; is the new object being created. &quot;Prototypes&quot; 
           is the list of prototypes for the object. If the list is missing, as 
           in this example, then just Object is assumed. &quot;body&quot; is the 
           exact same body that is in the &quot;with&quot; statement that is executed 
           exactly once immediately.</p>
+        <p>&nbsp;</p>
         </td>
     </tr>
   </table>
Modified: trunk/docs/tutorial/tutorial9.htm
===================================================================
--- trunk/docs/tutorial/tutorial9.htm	2004-05-18 06:47:42 UTC (rev 500)
+++ trunk/docs/tutorial/tutorial9.htm	2004-05-18 19:06:22 UTC (rev 501)
@@ -30,23 +30,25 @@
     </tr>
   </table>
   <br>
-  <table width="630" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffee" height="1707">
+  <table width="629" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffee" height="1707">
     <tr> 
       <td height="3212" valign="top">
-        <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a>6.4 
-          Initialization</font></p>
+        <p align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="init"></a>6.4 
+          Object Initialization</font></p>
         <p>When you create a thousand rectangles, you don't want them to all have 
           the same width and height. So it would be nice to have a convenient 
           way to give them their dimensions when they are created. Prothon has 
           provided a standard way of doing initialization of objects. </p>
-        <p>The form of creating an object that we gave earlier is incomplete. 
-          It is really &quot;newObject = Prototype(args)&quot;. Just as when calling 
-          a function, you can provide initialization parameters for object creation. 
-          For this to work your &quot;Prototype&quot; object or one of it's prototype 
-          parents must have a method called &quot;init_&quot; defined with the 
-          formal parameters defined that match the calling &quot;args&quot;. </p>
-        <p>When &quot;Prototype(args)&quot; is called, first the new object is 
-          created with the parent prototype of &quot;Prototype&quot; and no attributes 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oepargs"></a></font>The 
+          form of creating an object that we gave earlier is incomplete. It is 
+          really &quot;obj = Prototype(args)&quot;. Just as when calling a function, 
+          you can provide initialization parameters for object creation. For this 
+          to work your &quot;Prototype&quot; object or one of it's prototype parents 
+          must have a method called &quot;init_&quot; defined with the formal 
+          parameters defined that match the calling &quot;args&quot;. </p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="initbar"></a></font>When 
+          &quot;Prototype(args)&quot; is called, first the new object is created 
+          with the parent prototype of &quot;Prototype&quot; and no attributes 
           or binary data. Then the method &quot;init_&quot; is called with this 
           new object as &quot;self&quot;, or you could say &quot;init_&quot; is 
           called on the new object. If &quot;init_&quot; has a return statement 
@@ -74,9 +76,10 @@
         <p>The output of this file is:</p>
         <pre>5 12 60 
 10 17 170 </pre>
-        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a>6.4 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="subtypes"></a>6.5 
           Sub-types</font></p>
-        <p>Just as classes in object-oriented programming have sub-classes, prototypes 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="narrow"></a></font>Just 
+          as classes in object-oriented programming have sub-classes, prototypes 
           can have sub-types. A sub-type is simply an object that has a link to 
           a prototype but adds new methods or redefines a method. Usually a sub-type 
           is a narrowing of a category. For our example, we will use a square 
@@ -87,18 +90,20 @@
 ...       Rectangle.init_{self}(width, width)
 ...
 >>></pre>
-        <p>This may not be the best way to implement this, but it's an interesting 
-          way. Note that when you initialize the square, it calls the rectangle 
-          initialization routine with both width and height actual parameters 
-          equal to the square's one width. Let's look at the call closely. </p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="directcall"></a></font>This 
+          may not be the best way to implement this, but it's an interesting way. 
+          Note that when you initialize the square, it calls the rectangle initialization 
+          routine with both width and height actual parameters equal to the square's 
+          one width. Let's look at the call closely. </p>
         <pre>    Rectangle.init_{self}(width, width)</pre>
         <p>First of all, the call has the Rectangle's name at the beginning. This 
           is to make sure it gets the method from the Rectangle's attributes and 
           get's that version of the method that is expecting width and height. 
         </p>
-        <p>Next notice the &quot;{self}&quot;. If this wasn't there the self scope 
-          object would default to where the &quot;init_&quot; function came from, 
-          which would be the &quot;Rectangle&quot; object itself. So &quot;init_&quot; 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="selfcall"></a></font>Next 
+          notice the &quot;{self}&quot;. If this wasn't there the self scope object 
+          would default to where the &quot;init_&quot; function came from, which 
+          would be the &quot;Rectangle&quot; object itself. So &quot;init_&quot; 
           would be called on &quot;Rectangle&quot; instead of the new object that 
           needs to be initialized. In general, whenever you are calling an explicit 
           version of a method from an object (a &quot;directed&quot; call), like 
@@ -111,23 +116,28 @@
         <pre>>>> print sq.width, sq.area()
 7 49
 >>></pre>
-        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a>6.4 
-          Changing Types</font></p>
-        <p>Now I'd like to show you something useful that no object oriented language 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="chgtypes"></a>6.6 
+          Changing Object Types</font></p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="oaok"></a></font>Now 
+          I'd like to show you something useful that no object oriented language 
           can do. Most object-oriented languages will let you change an object 
           instance's type from a sub-type to a parent type. In other words go 
           from a narrower case to a broader case. Prothon will let you change 
           types of an object in either direction. </p>
-        <p>In this example we will modify the Rectangle prototype to intelligently 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="ctex"></a></font>In 
+          this example we will modify the Rectangle prototype to intelligently 
           recognize squares and then change the Rectangle object type to the more 
           specific type of Square.</p>
-        <p>Note several new things in this example. We are using the &quot;with&quot; 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="reopen"></a></font>Note 
+          several new things in this example. We are using the &quot;with&quot; 
           statement to &quot;re-open&quot; a prototype (Rectangle) and modify 
           an existing definition (init_) by replacing the old one. </p>
-        <p>We are using a method &quot;setProto&quot; which replaces all the existing 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="setProto"></a></font>We 
+          are using a method &quot;setProto&quot; which replaces all the existing 
           prototype links in an object with one new one. </p>
-        <p>We are defining a special method called &quot;str_&quot; that is used 
-          by print and other commands to represent an object in text form. Whatever 
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="strf"></a></font>We 
+          are defining a special method called &quot;str_&quot; that is used by 
+          print and other commands to represent an object in text form. Whatever 
           string object is returned by &quot;str_&quot; is what will be shown 
           for that object.</p>
         <p>In order to save typing, we'll run tut11.pr and use the console:</p>
@@ -155,7 +165,73 @@
 >>> print sq2, sq2.area()
 &lt;Square:15&gt; 225
 >>></pre>
-      </td>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="mulinh"></a>6.7 
+          Multiple Inheritance</font></p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="miwarn"></a></font>Prothon 
+          allows the object to have multiple prototype links which means that 
+          it can inherit from multiple parents. This multiple inheritance feature 
+          is powerful and should be used carefully as it can cause trouble if 
+          not used properly. Prothon will search all the parents of all the links 
+          for an attribute, but the search order can be complex when an object 
+          has multiple links to start from. If different parents on different 
+          paths have the same attribute you may not get the one you expect.</p>
+        <p><font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="miex"></a></font>Let's 
+          add a new prototype to our Rectangle example called Solid. This will 
+          be a &quot;mix-in&quot; prototype that has a &quot;depth&quot; attribute 
+          that makes our rectangles into three dimensional objects when added 
+          to them. It will also add a &quot;volume&quot; method that calculates 
+          the volume of the solid. Our goal is to be able to just add the Solid 
+          prototype to any Rectangle or Rectangle sub-type to make a Solid object.</p>
+        <p>In this example we will add the Solid prototype to the Square we developed 
+          before to turn the square into a cube. Our code for the Square and Rectangle 
+          here is the same. We are just adding the Solid prototype and using it 
+          to make the new prototype Cube.</p>
+        <pre>
+# Prothon source file tut12.pr
+
+object Rectangle:
+    width = 0
+    height = 0
+    
+    def init_(width, height):
+        self.width = width
+        self.height = height
+        
+    def area():
+        return self.width * self.height
+        
+object Square(Rectangle):
+    def init_(width):
+        Rectangle.init_{self}(width, width)
+
+object Solid:
+    depth = 0
+    
+    def initSolid(depth):
+        self.depth = depth
+    
+    def volume():
+        return self.area() * self.depth
+
+object Cube(Square, Solid):     # Cube has two prototypes
+    def init_(width):
+        Square.init_{self}(width)
+        self.initSolid(width)
+
+    def str_():
+        return '&lt;cube:'+self.width+'&gt;'
+
+cube = Cube(3)
+
+print cube, cube.area(), cube.volume()</pre>
+        <p>Here is the output: </p>
+        <pre>&lt;cube:3&gt; 9 27</pre>
+        <font face="Verdana, Arial, Helvetica, sans-serif" size="+2"><a name="mixin"></a></font>Note 
+        that we used a different type of initialization for Solid. Solid was only 
+        designed to be a mix-in and to be used this way, so its initialization 
+        is a simple method. You can see that it and the init_ call above it both 
+        have to specify &quot;self&quot; as the target &quot;self&quot; of the 
+        calls. </td>
     </tr>
   </table>
   <table width="630" border="0" cellpadding="0" cellspacing="0">
Added: trunk/pr/tutorial/tut12.pr
===================================================================
--- trunk/pr/tutorial/tut12.pr	2004-05-18 06:47:42 UTC (rev 500)
+++ trunk/pr/tutorial/tut12.pr	2004-05-18 19:06:22 UTC (rev 501)
@@ -0,0 +1,39 @@
+
+# Prothon source file tut12.pr
+
+object Rectangle:
+    width = 0
+    height = 0
+    
+    def init_(width, height):
+        self.width = width
+        self.height = height
+        
+    def area():
+        return self.width * self.height
+        
+object Square(Rectangle):
+    def init_(width):
+        Rectangle.init_{self}(width, width)
+
+object Solid:
+    depth = 0
+    
+    def initSolid(depth):
+        self.depth = depth
+    
+    def volume():
+        return self.area() * self.depth
+
+object Cube(Square, Solid):     # Cube has two prototypes
+    def init_(width):
+        Square.init_{self}(width)
+        self.initSolid(width)
+
+    def str_():
+        return '<cube:'+self.width+'>'
+
+cube = Cube(3)
+
+print cube, cube.area(), cube.volume()
+    
\ No newline at end of file