Next: , Previous: , Up: lang   [Index]


1.12 Callable objects

The library (vicare language-extensions callables) allows the definition of callable objects: closure objects associated to an object used as first argument in every call. Here is an example of callable object:

(import (vicare)
  (vicare language-extensions callables))

(define C
  (callable 123 (lambda (self delta)
                  (+ delta self))))

(callable? C)           ⇒ #t
(callable-object C)     ⇒ 123
(C 9000)                ⇒ 9123
Syntax: callable ?object ?function

Build and return a new callable object associated to ?object and having ?function as callable procedure.

Function: callable? obj

Return #t if obj is a callable object, otherwise return #f. Notice that a callable object satisfies procedure?.

Function: callable-object callable
Function: $callable-object callable

Return the object associated to the callable object callable. $callable-object is the unsafe version which does not validate its argument prior to accessing its internal fields.