The class class is the base class of all the other wwlisp classes. Symbolic atoms and lists have no class. All the other objects known in the language have a class, and hence can make use of the methods defined for the base class. In wwlisp , the concept of class is highly dynamic and volatile, and authorizes a lot of class hacking on existing objects, leading to a great conceptual freedom while at the cost of a lot of care. But freedom must always come with responsibility... |
Function Type | subr |
Arguments | an object and a symbol |
Return Value | a list or nil |
Description | if the class given as second argument is one of the ancestor of the object given as first argument, returns the list of ancestor classes of the class given; else returns nil |
Example | (ancestor stdin 'stream) => (stream class) |
Function Type | subr |
Arguments | an object and an object |
Return Value | an object |
Description | adds to the object given as first argument all the properties of the object given as second argument; when a property already exists in the target object, it is overriden by that of the source object; the class of the source object is then changed to 'class in order to disable the original destructor and avoid that because the copy of the properties being actually a shallow copy, the source destruction would also cause the destruction of some of the added properties of the target; the keyword 'exclude followed by a list of property-names excludes those from the copy; this is a class hacking method and should be used only with very great care |
Example | (combine targetobject sourceobject) |
Function Type | subr |
Arguments | the symbolic atom class |
Return Value | an object of class class |
Description | never use directly class-constructor but always call make-instance instead |
Example | (make-instance class) |
Function Type | subr |
Arguments | any object, not symbolic atom nor list |
Return Value | a copy of the object given as argument |
Description | this is the default copy function for any class; this function creates a new object which has the same property list than the original; when a property of one of the objects is modified with putprop, defprop or remprop, the property-list is duplicated up to the changed property and the original is left intact, performing a 'copy on write' for a part (or totality) of the property-list; this process is actually a shallow copy because the values of the properties are not duplicated but pointed to |
Example | (copy 33) => 33 |
Function Type | subr |
Arguments | an object of class class |
Return Value | nil |
Description | never use class-destructor directly but call it always through destroy-instance ; this is the default destructor for an object of any class; as there can be active references to an object being destroyed, the object is on place replaced by an empty list |
Example | (destroy-instance "hello" ) => replaces "hello" by an empty list |
Function Type | subr |
Arguments | an object |
Return Value | a string |
Description | is the default formatter of all classes; always returns the string "[unprintable-object]" |
Example | (format (make-instance class)) => "[unprintable-object]" |
Function Type | subr |
Arguments | an object and an object |
Return Value | an object |
Description | replaces the ancestry of the object given as first argument by the ancestry of the object given as second argument; the method returns the object given as first argument; the objects retain their properties; the object given as second argument is not modified at all; the (carvalue) of the object given as first argument is also unchanged; the result of the method is that the object given as first argument becomes of the class of the second argument and all its methods can be applied, while the original methods are not available anymore; the mutate method can for example change a string into an unsignedinteger , giving the address of the actual string in string space; on the contrary changing an unsignedinteger to a string leads to pointing somewhere in memory and very probably causing a real nasty SIGSEGV and abort; this is a class hacking method and should be used only with very great care |
Example | (mutate "hello" 0x0) => 0xb5b3696a |
Function Type | expr |
Arguments | an object |
Return Value | nil |
Description | prints nicely on stdout all the properties of an object, including the properties which are binary blocks; to do the dump of the internals of a block, class-show invokes the most specific showbin method for the object; if that method is succesful, it is expected to return t; if nil was returned by showbin, class-show retries with a less specific method, walking the inheritance list of the object |
Example | (show stdin) => prints the status of stdin |
Function Type | expr |
Arguments | object, binary block, integer |
Return Value | t or nil |
Description | never use that function directly, but call show instead; class-showbin is the default method for printing the length of a binary block used as a property of an object; normally each class using binary blocks must provide the adequate showbin method to dump them nicely on stdout; as there is only one possible showbin method for one specific class (not including the parent classes), if the specific class uses several binary blocks, the showbin method must be able to identify which is which in order to print it correctly; the showbin method can use any hint to do this, for example the length of the block; if the block is recognized and printable, the method must print it on stdout and return t; otherwise it must return nil, which will give the control back to the body of class-show which will try another showbin method, from a parent class |
Example | (show stdout) |