method¶
fun method::list(): list[method]
TBD
fun method::isolate(Args: any, ..., Fn: function): any
Evaluates
Fn(Args)
in a new method context and returns the result.type method < function
A map of type signatures to functions. Each type signature consists of a number of types and a flag denoting whether the signature is variadic.
(M: method)(Arg₁, ..., Argₙ)
Calls
Fn(Arg₁, ..., Argₙ)
whereFn
is the function associated with the closest matching type signature defined inM
.A type signature
(Type₁, ..., Type/k, Variadic)
matches iftype(Argᵢ) < Typeᵢ
for each \(i = 1, ..., k\) and either \(n = k\) or \(n < k\) and \(Variadic\) is true.A type signature is considered a closer match if its types are closer in terms of subtyping to the types of the arguments.
A type signature with the same number of types as arguments is considered a closer match than a matching variadic signature with fewer types.
meth method(Name: string): method
Returns the method with name
Name
.meth method(): method
Returns a new anonymous method.
meth (Arg₁: method):MLMethodDefault(...)
TBD
meth (Arg₁: method)[...]
TBD
meth (Arg₁: method):list
TBD
meth method::define(Method: method, Types: type, ..., ..?: any, Function: function): Function
Adds a new type signature and associated function to
Method
. If the last argument is..
then the signature is variadic. Method definitions usingmeth
are translated into calls tomethod::set
.meth (Method: method):name: string
Returns the name of
Method
.meth (Arg₁: string::buffer):append(Arg₂: method)
TBD
meth (Arg₁: string::buffer):append(Arg₂: method::anon)
TBD
type method::context
A context for isolating method definitions.
(C: method::context)(Args: any, ..., Fn: function): any
Calls
Fn(Args)
in a new context usingC
for method definitions.
fun method::context(): method::context
Returns a new context for method definitions. The new context will inherit methods definitions from the current context.