--- freem/doc/freem.texi 2025/05/05 04:46:35 1.42 +++ freem/doc/freem.texi 2025/05/05 05:16:34 1.44 @@ -4,8 +4,7 @@ @settitle The FreeM Manual @copying -This manual is for FreeM, (version 0.64.0-rc1), which is a free software@footnote{FreeM subscribes to the software licensing philosophy described in @emph{Free Software, Free Society: -Selected Essays of Richard M. Stallman}.} implementation of the M programming language. +This manual is for FreeM, (version 0.64.0-rc1), which is a free software implementation of the M programming language. Print-optimized versions of this book are typeset in @emph{Computer Modern} by the author using the @emph{GNU Texinfo} tools. @@ -4590,7 +4589,7 @@ SET MYSTRING="This is a ""string literal @cindex types, custom @cindex classes -See @ref{Classes}. +See @ref{Object-Oriented Programming}. @node Globals @chapter Globals @@ -4945,20 +4944,8 @@ If you use other M implementations, you @cindex object-oriented programming @cindex programming, object-oriented -@menu -* Classes:: The basis of object-oriented programming. -* Inheritance:: Basing one class upon another. -* Methods:: Attaching code to a class. -* Public and Private Variables:: Managing class member access. -* Instantiating Objects:: Creating instances of classes. -* Determining Object Class:: Getting object information at runtime. -@end menu -@node Classes @section Classes - - -@node Class Overview @subsection Class Overview A @emph{class} is the primary organizing concept of FreeM support for object-oriented programming, and in FreeM, is simply an M routine with a few special properties: @@ -4976,7 +4963,6 @@ DESTROY(THIS) ; This is the destructor The above example demonstrates general class syntax. -@node Constructors @subsection Constructors A @emph{constructor} is an M entry point that is called when a new instance of a class is created. @@ -5001,7 +4987,6 @@ A constructor looks like this: In the above example, @emph{} represents the name of a class from which this class should inherit. In this case, the @code{FRACTION} class inherits from the @code{OBJECT} class. Note that this is not strictly necessary in this case, as all classes in FreeM automatically inherit from @code{OBJECT}. -@node Destructors @subsection Destructors A @code{destructor} is called when you @code{KILL} an instance variable. Its tag must be @code{DESTROY}, and it must take one argument (@code{THIS}). @@ -5015,7 +5000,6 @@ DESTROY(THIS) ; Q @end example -@node Inheritance @section Inheritance Every class you create will automatically inherit the methods and functionality of the @code{OBJECT} class, supplied with FreeM. @@ -5028,14 +5012,12 @@ Inheritance is achieved by specifying th CLASS(THIS,INIT):SUPERCLASS @end example -@node Runtime Polymorphism @subsection Runtime Polymorphism You can achieve runtime polymorphism by subclassing, and defining methods in the subclass that match the names of existing methods in the superclass. Following FreeM inheritance rules, the overridden method in the subclass will be called, and the method in the superclass will not. Note that the overridden method in the subclass can take a different set or number of arguments than the @emph{formallist} of the superclass method would specify. -@node Methods @section Methods Class methods are defined as tags with @emph{formallist}s in a class routine, and per the typical FreeM object pattern, must take at least one argument, being @code{THIS} (representing a reference to the object instance being accessed). @@ -5058,7 +5040,6 @@ DEFAULT.USER> W MYOBJ.MYMETHOD() VALUE @end example -@node Public and Private Variables @section Public and Private Variables FreeM supports private fields with the @code{:PRIVATE} specifier in the @code{SET} command, enforcing classical object-oriented data encapsulation. The @code{:PUBLIC} specifier is provided for completeness, and is the default. @@ -5081,7 +5062,6 @@ Either of the following commands will cr Attempting to access private fields from outside of the class will raise error condition @code{ZOBJFLDACCV}. -@node Instantiating Objects @section Instantiating Objects To instantiate an object (i.e., create an object from a certain class), you will use the @code{NEW} command as follows: @@ -5092,7 +5072,6 @@ NEW MYSTR=$#^%STRING("myString") This will create a local variable called MYSTR of type STRING, and initialize it with the value myString. -@node Determining Object Class @section Determining Object Class To determine the class of any FreeM local variable, you will use the @code{$$TYPE()} method: