defclass
|
The defclass Macro creates a new class Lambda object and assigns it to the specified className.
The defclass Macro always returns the newly created class Lambda. Following the
defclass Macro, the new class Lambda can be used to create new objects (class Structures)
of the type className. For instance below we define a class Lambda, create an object of the class, and then
invoke the various class methods. Usage Use the defclass when a new class Lambda is to be created.
(defclass employee()
svars:(String:Name (Number:Salary 0.0))
cvars:(empStatic)
(defun new(self name salary)
(setq Name (string name))
(setq Salary salary)
self) ;; end of new method
(defun talk(self)
(writeln "I " Name " am an employee.")
true) ;; end of talk method
;;.... other class methods here
true) ;; end of employee class
(defclass employee:manager()
svars:(String:Title)
(defun talk(self)
(writeln "I " Name " am a manager.")
true) ;; end of talk method
;;.... other class methods here
true) ;; end of manager class
;; Creating objects form each of two classes.
(setq emp (new employee "John Doe" 24000.0)) ;; Create an object of class employee
(setq mgr (new manager "Chuck Bigman" 36000.0)) ;; Create an object of class manager
;; Invoking methods on each object.
(talk:emp) ;; writes on console, "I John Doe am an employee."
(talk:mgr) ;; writes on console, "I Chuck Bigman am a manager."
(class mgr) ;; returns "manager"
(defclass className(arg...) svars:(var...) faces:(var...) pvars:(var...)
cvars:(var...) regs:(var...) vars:(var...) exp...) (defclass parent:className(arg...) svars:(var...) faces:(var...) pvars:(var...)
cvars:(var...) regs:(var...) vars:(var...) exp...) An class Lambda that will be assigned the className.
Expression:
Arguments
Name
Type
Description Argument: parent: Symbol
(Optional) The Parent class Lambda from which this class will inherit. Argument: className Symbol
The name of the new class Lambda. Argument: (arg...) ---
Optional Argument. Argument list for the Lambda. Argument: svars:(var...) Symbol
The list of class variables which become part of each class Structure created by the class. Argument: faces:(var...) Symbol
Optional Argument. If present, must be followed by a interfaces feature list. Argument: vars:(var...) Symbol
Optional Argument. If present, must be followed by a local variable list. Argument: pvars:(var...) Symbol
Optional Argument. If present, must be followed by a persistent variable list. Argument: cvars:(var...) Symbol
Optional Argument. If present, must be followed by a persistent class variable list. Argument: regs:(var...) Symbol
Optional Argument. If present, must be followed by a register variable list
(up to fifty register variables are allowed). Argument: exp... ---
The Lisp statements that forms the Lambdas
Returns:
Here are a number of links to Lambda coding examples which contain this instruction in various use cases.
Here are the links to the data types of the function arguments.
Lambda | Symbol |
Here are also a number of links to functions having arguments with any of these data types.
Analytic Information Server (AIS)AIS Component Systems
|