defmethod

 

 

Overview

The defmethod Macro adds a new method Lambda methodName to the specified class Lambda className. The defmethod Macro always returns the newly created methods Lambda. Following the defmethod Macro, the new method Lambda can be invoked on any objects (class Structures) of the specified className.

For instance below we define a class Lambda, create an object of the class, and then invoke the various class methods.

(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

(defmethod employee:brag()
      (writeln "I " Name " earn " Salary " dollars per year.")
      true) ;; end of brag method
   true) ;; end of brag method

;; 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.
(brag:emp) ;; writes on console, "I John Doe make 24,000 per year."
(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"

Usage

Use the defmethod when a new class Lambda is to large to be contained in a single source file, or when each class method is to be kept in its own source file.

 

Syntax


Expression:

(defmethod className:methodName(arg...) svars:(var...) faces:(var...) pvars:(var...) cvars:(var...) regs:(var...) vars:(var...) exp...)


Arguments Name Type Description
Argument:classNameSymbol The class Lambda to which this method will be added.
Argument:methodNameSymbol The name of the new method 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:

An class Lambda that will be assigned the className.



 

Examples

Here are a number of links to Lambda coding examples which contain this instruction in various use cases.

 

Argument Types

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.

++ += /= *=
-- -= addMethod append
apply argCount argFetch attachLibrarian
balance binaryInsert binarySearch boolean
callcc cdr character class
compareEQ compareGE compareGT compareLE
compareLT compareNE compare comparison
compile compress cons copy
count debugBrowsableProcs debug defchild
defclass define(macro) define defmacro
defmethod deforphan defriend defun
delete detachLibrarian dimension disassemble
display downcase encode evalInSyncLocalContext
eval exportCsv exportSbf exportTab
gc getGlobalValue getSymbolTable globalBinding
importCsv importSbf importTab insert
inside inspect integer isAtom
isBitVector isBoolean isByteVector isCharAlphabetic
isCharAlphanumeric isCharLowercase isCharName isCharNumeric
isCharUppercase isCharWhitespace isChar isCharacter
isClass isComplex isDate isDictionary
isDirectory isEqual isError isFloatVector
isIdentical isInside isIntegerVector isInteger
isLambda isMatrix isMember isMoney
isNumberMatrix isNumberVector isNumber isObjectVector
isObject isPair isPcodeVector isString
isStructure isSymbol isText isType
isVector lambda length lisp
list lock macroReplace makeLambda
makeQuotedList makeQuotedSymbol member methodsOf
money myself new number
offset onError openLog pair
parent parse pointer proplist
proprecord putprop qt refLibrarian
ref remProp remove rename
saveObject saveRepository send setCar
setCdr setLastCdr set setf
setq sizeof sql string
super svmRegression symbolToTypeCode symbol
type uniqueInsert unlock vectorFill
writelg writeln

Analytic Information Server (AIS)

AIS Component Systems

  • Smartbase Engine
  • QT C++ Libraries
  • MySQL Relational Database
  • AIS Lisp Libraries
  • Rapid Analytic Demo IDE