parametric class categories
Objects, Classes and Slots
Calls and Slot Access
Updates

Calls and Slot Access

Calls are the basic building blocks of a CLAIRE program. A call is a polymorphic function call (a message) with the usual syntax : a selector followed by a list of arguments between parentheses. A call is used to invoke a method.

When the selector is an operation, such as +, -, %, etc... (% denotes set membership) an infix syntax is allowed (with explicit precedence rules) :
 eval(x), f(x,y,z), x.pricey.name
If a slot is read before being defined (its value being unknown), an error is raised. This only occurs if the default value is unknown. To read a slot that may not be defined, one must use the get(r:property,x:object) method :
 John.father // may provoke an error if John.father is unknown
 get(father,john// may return unknown
When the selector is an operation, such as +,-,%,etc... (% denotes set membership) an infix syntax is allowed (with explicit precedence rules). Hence the following expressions are valid :
 1 + 2
 1 + 2 * 3
Note that new operations may be defined. This syntax extends to boolean operations (and:& and or:|). However, the evaluation follows the usual semantic for boolean expression (e.g., (x & y) does not evaluate y if x evaluates to false) :
 (x = 1& ((y = 2| (y > 2)) & (z = 3)
The values that are combined with and/or do not need to be boolean values (although boolean expressions always return the boolean values true or false). Following a philosophy borrowed from LISP, all values are assimilated to true, except for false, empty lists and empty sets. The special treatment for the empty lists and the empty sets yields a simpler programming style when dealing with lists or sets. Notice that in CLAIRE 3.0, contrary to previous releases, there are many empty lists since empty lists can be typed (list<integer>(), list<string>(), ... are all different).

A dynamic functional call where the selector is evaluated can be obtained using the call method. For instance, call(+,1,2) is equivalent to +(1,2) and call(show,x) is equivalent to show(x). The difference is that the first parameter to call can be any expression. This is the key for writing parametric methods using the inline capabilities of CLAIRE. This also means that using call is not a safe way to force dynamic binding, this should be done using the property abstract. An abstract property is a property that can be re-defined at any time and, therefore, relies on dynamic binding. Notice that call takes a variable number of arguments. A similar method named apply can be used to apply a property to an explicit list of arguments.

Since the use of call is somehow tedious, CLAIRE supports the use of variables (local or global) as selectors in a function call and re-introduce the call implicitly. For instance :
 compose(f:propertyg:propertyx:any: any
     => f(g(x))
is equivalent to :
 compose(f:propertyg:propertyx:any)
     => call(fcall(g,x))


categories Calls and Slot Accessnormal dispatch Core method

apply(m:method, l:list) -> any

apply(m,lx) applies the method m to the argument list lx. For instance the following expressions are equivalent :
 apply(+ @ integerlist(13)) -> 4
 1 + 3 -> 4


categories Calls and Slot Accessnormal dispatch Core method

apply(self:lambda, %l:list) -> any

apply(self,%l) applies the lambda expression self to the argument list %l.


categories Calls and Slot Accessnormal dispatch Core method

apply(p:property, l:list) -> any

apply(p,l) is equivalent to a function call where the selector is p and the argument list is l. For instance the following expressions are equivalent :
 apply(+list(1,2)) -> 3
 1 + 2 -> 3
 call(+12-> 3


categories Calls and Slot Accessnormal dispatch Core method

apply(self:function, ls:list, l:list) -> any

apply(self,ls,l) applies the function self to the argument list l, where ls is the list of sort of the arguments and the result (i.e. length(ls) = length(l) + 1). For instance, if self is the external function that defines + @ integer :
 apply(flist(integer,integer,integer), list(1,2)) -> 1 + 2


categories Calls and Slot Accessnormal dispatch Core method

call(p:property, l:listargs) -> any

call(p, x1, x2, ..., xn) is equivalent to apply(p, list(x1 ,x2 , ... , xn)).


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(m:method, x:any) -> void

funcall(m,x) applies a method with one argument


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(l:lambda, x:any) -> void

funcall(l,x) applies a lambda with one argument


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(m:method, x:any, y:any) -> void

funcall(m,x,y) applies a method with two argument


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(l:lambda, x:any, y:any) -> void

funcall(l,x,y) applies a lambda with two argument


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(f:function, s1:class, x:any, s:class) -> void

funcall provides an easy interface with external (C++) functions. funcall(f, s1, x, s) applies an external function to an argument of sort s1. The sort of the returned value must be passed as an argument. Notice that the last argument is the sort of the result, and that giving an erroneous sort argument will likely produce a fatal error.


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(m:method, x:any, y:any, z:any) -> void

funcall(m,x,y) applies a method with three argument


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(l:lambda, x:any, y:any, z:any) -> void

funcall(l,x,y) applies a lambda with three argument


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(f:function, s1:class, x:any, s2:class, y:any, s:class) -> void

like funcall(f, s1, x, s) but for external functions with two arguments.


categories Calls and Slot Accessnormal dispatch Kernel method

funcall(f:function, s1:class, x:any, s2:class, y:any, s3:class, z:class, s:class) -> void

like funcall(f, s1, x, s) but for external functions with three arguments.