lib/allTypes.spl)
Defines class AllTypes with instance methods
print and return that branch on
type.* and call the matching typed
print.* and return.* in the interpreter.
Load with use allTypes; (extensionless allowed).
use allTypes;
class.createObj(at, AllTypes);
at.print("hello");
functionDefine.foo():
at.return("from function");
end;
at.print(function.foo());
at.return in functions
When at.return(expr) appears as a standalone statement
inside a user-defined function, the interpreter treats it like a normal
return.*: it exits that function with the value (for the
AllTypes return method only—same implementation as in
lib/allTypes.spl).
When at.return(expr) is used inside an expression
(for example y.setVar(at.return(3));), it only supplies the return value of the
instance method call, not the outer function.
Use obj.methodName(args); after
class.createObj. See
Classes & OOP for details.
Implementation: someProgrammingLanguage/lib/allTypes.spl