method¶
fun method::list(): list[method]TBD
fun method::isolate(Args: any, ..., Fn: function): anyEvaluates
Fn(Args)in a new method context and returns the result.fun mlmethodisolated(Arg₁: any)TBD
type method < functionA 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ₙ)whereFnis 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(): methodReturns a new anonymous method.
meth method(Name: string): methodReturns the method with name
Name.meth (Arg₁: method)[...]TBD
meth (Arg₁: method):cachedTBD
meth (Arg₁: method):listTBD
meth method::default(Method: method, ...): errorThe default handler for method calls with no matching signature. Returns an error describing the missing signature.
This method can be overridden to create remote proxies, custom error method errors, etc.
"A" *** "B" :> error("MethodError", "no method found for ***(string, string)") 2 *** "B" :> error("MethodError", "no method found for ***(integer32, string)") meth method::default(M: method, X: number, [Y]) 'New default handler! ({M}, {X}, {Y})' :> @:1 "A" *** "B" :> error("MethodError", "no method found for ***(string, string)") 2 *** "B" :> "New default handler! (:***, 2, [B])"
meth method::define(Method: method, Types: type, ..., ..?: any, Function: function): FunctionAdds a new type signature and associated function to
Method. If the last argument is..then the signature is variadic. Method definitions usingmethare translated into calls tomethod::set.meth (Method: method):name: stringReturns the name of
Method.meth (Arg₁: string::buffer):append(Arg₂: method)TBD
meth (Arg₁: string::buffer):append(Arg₂: method::anon)TBD
type method::contextA context for isolating method definitions.
(C: method::context)(Args: any, ..., Fn: function): anyCalls
Fn(Args)in a new context usingCfor method definitions.
fun method::context(): method::contextReturns a new context for method definitions. The new context will inherit methods definitions from the current context.
type method::isolated < functionTBD