send
|
The send special form invokes a method of an object.
The methods invocation may include 0 or more arguments. Here we define a class Lambda, create an object of the class, and then
use the send special form to invoke a method of the newly created object. Usage The send special form can only be used to invoke a method of a class Structure or
a class Lambda. The send Special Form causes a lookup of the method
name argument in the class methods Structure. If the method name is found, the Lambda bound
to the method name will be invoked.
(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
;; Using send to invoke a method of an object created by a class Lambda
(setq emp (new employee "John Doe" 24000.0)) ;; Create an object of class employee
(send talk:emp) ;; writes on console, "I John Doe am an employee."
;; Using a short cut to send
(talk:emp) ;; writes on console, "I John Doe am an employee."
;; Using a ref instead of send
(emp.talk emp) ;; writes on console, "I John Doe am an employee."
;; Invoking the class method directly instead of send
(employee.talk emp) ;; writes on console, "I John Doe am an employee."
(send methodName object) (send methodName object arg1 arg2...) (methodName object) (methodName object arg1 arg2 ...) Dependents upon the method invoked.
Expression:
Arguments
Name
Type
Description Argument: methodName Symbol
The name of the method to be invoked Argument: object Structure or Lambda
The target object of the message. Argument: args... all types
(Optional) The argument list.
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.
Structure | or | Lambda |
Here are also a number of links to functions having arguments with any of these data types.
Analytic Information Server (AIS)AIS Component Systems
|