Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
A class is a bundle of data (members) along with the functions (methods) which operate on it. It is somewhat similar to a curry, inasmuch as "data hiding" or "encapsulation" takes place, the data only being directly manipulable by the member function (methods) or curried functor. The data and methods are enclosed as a struct in a Buf. By default, for consistency with normal structs, members are public unless declared with "£" in front of the name (No connection with the use of "£" in the GHOST header), when the item becomes private (only accessible to the class methods).
MyClass <:: ( // Declare my class;
foo=&{ (...locals to foo ...)
...function body of foo...
}, bar=&{
(...locals to bar ...)
...function body of bar ...
}, a=1, £b=42
); // End class definition;
MyClass -::> instance; // Make an instance of the class;
Note that member "a" is accessible outside the class, for example as "instance.a", whereas "b" is private, and cannot be referenced. foo() and bar() are public, and can be called as "instance.foo()" and "instance.bar()".