On this page:
Callable
8.17.0.6

9.9 Callables🔗ℹ

Provided only in the class space, not the annot or namespace space.

An interface that a class can implement (publicly or privately) to make instances of the class callable as functions. The interface has one abstract method, which must be overridden to implement the behavior of function calls:

  • call receives the arguments that are passed to the instance that is called as a function, and the method’s result is the result of the function call.

class Posn(x, y):

  private implements Callable

  private override method call(dx, dy):

    Posn(x + dx, y + dy)

> def p = Posn(1, 2)

> p

#<function:Posn>

> p(3, 4)

#<function:Posn>