Quirrel4.41.0

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

__mergepure (table|class).__merge(other: table|instance|class, ...): anyBuilds 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, ...): anyCopies every own member of each argument into the class it is called on, and returns that same class. Unlike __merge, nothing new is allocated.
acallclass.acall(args: array): anyCreates 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.
callclass.call(...): anyCreates 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.
cloneclone(): anyAlways fails. clone is one of the type-methods every built-in delegate carries, but the VM's generic clone operation explicitly refuses a class.
getbasepure class.getbase(): anyReturns the class this class inherits from.
getfuncinfosclass.getfuncinfos(): anyDescribes the class's _call metamethod, the same way function.getfuncinfos describes a plain function.
getmetamethodclass.getmetamethod(name: string): anyLooks up one of the class's metamethods by name, without triggering it.
hasindexpure class.hasindex(key): anyTests whether key names a member of the class.
instanceclass.instance(): anyCreates a new instance of the class without running its constructor.
is_frozenis_frozen(): anyReports whether this reference to the class was frozen with freeze().
lockclass.lock(): anyLocks the class immediately, without creating an instance.
newmemberclass.newmember(key, value, ...): anyAdds a member to the class, optionally as a static one.
pacallclass.pacall(args: array): anySame as acall, except a failure does not invoke the VM's registered error callback.
pcallclass.pcall(...): anySame as call, except a failure does not invoke the VM's registered error callback.
rawgetpure class.rawget(key): anyReads the value stored at key in the class's own member table.
rawinpure class.rawin(key): anyTests whether key names a member of the class.
rawsetclass.rawset(key, value): anyCreates or replaces a member of the class, and unlike newmember, wires key and value to the roles their names suggest.
tostringtostring(): anyConverts the class to a string.
weakrefweakref(): anyReturns a weak reference to the class.