Permalink
Browse files

documentation updates

  • Loading branch information...
1 parent 112c272 commit 1b250e26091696c499119c3d6c19b82daff3740c @pdt committed Jul 10, 2012
Showing with 165 additions and 5 deletions.
  1. +165 −5 doc/nso.html
View
@@ -311,7 +311,7 @@ <h2>get and set Subcommands</h2>
</p>
<p>
-The set subcommand also supports switches, this time <code>-vars</code> and
+The set subcommand supports the switches <code>-vars</code> and
<code>-fromDict</code>. When setting properties with <code>-vars</code>, only
the property names are specified in the command, and values are taken from
local variables of the same name. With the <code>-fromDict</code> switch, a
@@ -377,8 +377,8 @@ <h2>Inheritance</h2>
<p>
Methods in a base class may be overridden in a derived class with the
-<code>override</code> command. Access to overridden methods is however still
-available through the <code>super</code> command.
+<code>override</code> command. Access to overridden methods is available
+through the <code>super</code> command.
</p>
<div class="codebox">
@@ -405,7 +405,7 @@ <h2>Inheritance</h2>
To support a composition over inheritance style of programming, a
<code>forward</code> command is provided for forwarding property access and
method invocation on to another object. The property and method names to
-foward are provided as arguments to the forward command, followed by the class
+forward are provided as arguments to the forward command, followed by the class
and object to forward to.
</p>
@@ -433,11 +433,171 @@ <h2>Inheritance</h2>
</pre>
</div>
-
<h2>Interfaces</h2>
+<p>
+An interface defines properties, with the <code>properties</code> command, and
+methods, with the <code>method command</code>, to be implemented by a class.
+A class may implement one or more interfaces by using <code>implements</code>
+when defining a class. If more than one interface is being implemented, the
+interfaces should be grouped to form a list. The class must implement all
+aspects of the interfaces it declares it's implementing, otherwise an error is
+generated.
+</p>
+
+<div class="codebox">
+<pre>
+interface Point {
+ properties x y
+}
+
+interface Shape {
+ method moveTo {newX newY}
+ method rMoveTo {deltaX deltaY}
+ method draw {}
+}
+
+class Circle implements {Point Shape} {
+ ...
+}
+</pre>
+</div>
+
+<p>
+Interfaces may also declare readonly and common properties, and common methods.
+</p>
+
+<div class="codebox">
+<pre>
+interface MyInterface {
+ properties a ;# public property
+ ro properties b c ;# readonly properties
+ common properties e ;# common property
+ ro common properties f g ;# readonly common properties
+ method aMethod {} ;# method
+ common method bMethod {} ;# common method
+ ...
+}
+</pre>
+</div>
+
<h2>Class Libraries</h2>
+<p>
+Classes (and interfaces) can be placed in class libraries by preceding a
+class name with the library when defining a class.
+</p>
+
+<div class="codebox">
+<pre>
+# class Dog is part of the .animals library
+class animals.Dog {
+ ...
+}
+
+# class EditDlg is part of the .myproj.gui library
+class myproj.gui.EditDlg {
+ ...
+}
+</pre>
+</div>
+
+<p>
+<em>Note:</em> when defining a class or interface, if the name doesn't start
+with a dot, one is assumed. Mostly, the initial dot can be ignored, but
+strictly speaking, it is part of the absolute name of a class or interface.
+</p>
+
+<p>
+When creating an instance of a class, the full name (including library part)
+of the class may be specified, and an instance of the class will be created.
+If the full class name isn't specified, then a name resolution process is
+undertaken to find the class to instantiate.
+</p>
+
+<p>
+If a class name isn't fully specified and is being instantiated inside another
+class, and that class is itself part of a library, the instantiated class is
+first looked for in that library, and if not found there, will be looked up in
+classes defined outside of any library.
+</p>
+
+<div class="codebox">
+<pre>
+class AppData {
+ ...
+}
+
+class containers.List {
+ ...
+}
+
+class animals.Cat {
+ ...
+}
+
+class animals.Dog {
+ variables appData aList bList cat
+ ...
+ constructor {} {
+ set appData [new AppData] ;# AppData not in library, so found
+ set aList [new List] ;# different library, error
+ set bList [new containers.List] ;# library specified, found
+ set cat [new Cat] ;# same library, found
+ ...
+ }
+ ...
+}
+</pre>
+</div>
+
+<p>
+The name resolution process can be modified by using using <code>from</code>
+when defining a class, or using the <code>from</code> command.
+</p>
+
+<p>
+When using <code>from</code> when defining a class, search libraries are
+listed. Then, any new objects created inside the class that aren't fully
+specified will be searched for in those libraries as well.
+</p>
+
+<div class="codebox">
+<pre>
+class animals.Dog from containers.* {
+ ...
+ constructor {} {
+ ...
+ set aList [new List] ;# using from, now found
+ ...
+}
+</pre>
+</div>
+
+<p>
+If using <code>from</code> when defining a class and more than one library is
+listed, the libraries should be grouped to form a list.
+</p>
+
+<p>
+The <code>from</code> command modifies the name resolution process on a per
+namespace basis.
+</p>
+
+<div class="codebox">
+<pre>
+class containers.List {
+ ...
+}
+
+set aList [new containers.List] ;# library specified, found
+set bList [new List] ;# error
+
+from containers.*
+set cList [new List] ;# from command includes containers, found
+</pre>
+</div>
+
<h2>Namespaces</h2>
<p>

0 comments on commit 1b250e2

Please sign in to comment.