--- freem/doc/freem.texi 2025/05/05 05:16:34 1.44 +++ freem/doc/freem.texi 2025/05/05 12:34:02 1.45 @@ -4944,7 +4944,15 @@ If you use other M implementations, you @cindex object-oriented programming @cindex programming, object-oriented +@menu +* Classes:: The organizing concept of object-oriented programming. +* Inheritance:: Making one class derive from another. +* Methods:: Attach code to classes. +* Public and Private Variables:: Determining accessibility. +* Instantiating Objects:: Creating instances of classes. +@end menu +@node Classes @section Classes @subsection Class Overview @@ -5000,6 +5008,7 @@ 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. @@ -5018,6 +5027,7 @@ You can achieve runtime polymorphism by 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). @@ -5040,6 +5050,7 @@ 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. @@ -5062,6 +5073,7 @@ 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: @@ -5072,7 +5084,7 @@ NEW MYSTR=$#^%STRING("myString") This will create a local variable called MYSTR of type STRING, and initialize it with the value myString. -@section Determining Object Class +@subsection Determining Object Class To determine the class of any FreeM local variable, you will use the @code{$$TYPE()} method: