Example Lambda send 008
|
In this example, we will first define a simple Lambda that simply takes a
number and computes the square of that number. We will use the defmethod
to install the message named: square, and the associated Lambda containing the
single statement required to compute the square of an input number. In order to
demonstrate the send command for an Lambda object, we will define a second
Lambda that will become the argument of the square message. The send
command will determine which Methods Dictionary to use based on the type of the
argument of the message. Since we want to install the square message and its
method, we need to specify the first argument as an Lambda object.
Notes and Hints Dissecting the send command involves understanding the methods dictionary
of any Analytic Information Server type. In general the send command is translated
as a reference into the methods dictionary: ((ref (methodsOf (type object)) methodName object)) The statement : (send square: aNumLambda aNumLambda .p1) is translated into ((ref (methodsOf (type aNumLambda )) square: ) aNumLambda aNumLambda.p1) Each statement segment results in:
Returns:
Returns:
Returns:
Returns:
Returns:
(type aNumLambda)
Returns: Lambda: (methodsOf (type aNumLambda))
Returns: #<Dictionary 123456> (ref (methodsOf (type aNumLambda)) square: )
Returns: #<Lambda 123456> ((ref (methodsOf (type aNumLambda)) square: ) aNumLambda aNumLambda.p1)
Returns: 100
Here are examples of the send function at work.
Here is the link to the current function used in this example.
Here are a number of links to other related functions.
addMethod(#void) | defMethod(#void) | methodsOf(#void) |
Here are the links to the data types of the arguments used in this example. Here are a number of links to examples having similar argument types.
Lambda
Dictionary
Analytic Information Server (AIS)AIS Component Systems
|