class
Methods on every class.
Call these with .$
A class's members and its built-in methods share one namespace, and a member wins. A class that declares a field called rawget, tostring or weakref hides the method of that name, and the ordinary call then fails with attempt to call 'string' or whatever the field happens to hold.
Writing the call as obj.$rawget(key) reaches the built-in type method directly and never looks at the members, so the class declaration cannot break it. Plain obj.rawget(key) is fine for a class you wrote yourself.
See the .$ operator and types.Table.
Functions
| __merge | pure (table|class).__merge(other: table|instance|class, ...): any | Builds a new class out of the class it is called on plus every argument given, and returns it. The class it is called on is not changed. |
| __update | (table|class).__update(other: table|instance|class, ...): any | Copies every own member of each argument into the class it is called on, and returns that same class. Unlike __merge, nothing new is allocated. |
| acall | class.acall(args: array): any | Creates a new instance of the class, passing it the constructor arguments packed into an array. Equivalent to call, only with the arguments collected into one array instead of listed one by one. |
| call | class.call(...): any | Creates a new instance of the class and runs its constructor, the same as writing ClassName(...). Exists so a class value obtained indirectly (through a variable, a table slot, or getclass()) can still be instantiated through a uniform .call(...) spelling shared with functions. |
| clone | clone(): any | Always fails. clone is one of the type-methods every built-in delegate carries, but the VM's generic clone operation explicitly refuses a class. |
| getbase | pure class.getbase(): any | Returns the class this class inherits from. |
| getfuncinfos | class.getfuncinfos(): any | Describes the class's _call metamethod, the same way function.getfuncinfos describes a plain function. |
| getmetamethod | class.getmetamethod(name: string): any | Looks up one of the class's metamethods by name, without triggering it. |
| hasindex | pure class.hasindex(key): any | Tests whether key names a member of the class. |
| instance | class.instance(): any | Creates a new instance of the class without running its constructor. |
| is_frozen | is_frozen(): any | Reports whether this reference to the class was frozen with freeze(). |
| lock | class.lock(): any | Locks the class immediately, without creating an instance. |
| newmember | class.newmember(key, value, ...): any | Adds a member to the class, optionally as a static one. |
| pacall | class.pacall(args: array): any | Same as acall, except a failure does not invoke the VM's registered error callback. |
| pcall | class.pcall(...): any | Same as call, except a failure does not invoke the VM's registered error callback. |
| rawget | pure class.rawget(key): any | Reads the value stored at key in the class's own member table. |
| rawin | pure class.rawin(key): any | Tests whether key names a member of the class. |
| rawset | class.rawset(key, value): any | Creates or replaces a member of the class, and unlike newmember, wires key and value to the roles their names suggest. |
| tostring | tostring(): any | Converts the class to a string. |
| weakref | weakref(): any | Returns a weak reference to the class. |