Module object

Prototype-based objects

  • Create an object/class:
    • object/class = prototype {value, ...; field = value ...}
    • An object's metatable is itself.
    • In the initialiser, unnamed values are assigned to the fields given by _init (assuming the default _clone).
    • Private fields and methods start with "_".
  • Access an object field: object.field
  • Call an object method: object:method (...)
  • Call a class method: Class.method (object, ...)
  • Add a field: object.field = x
  • Add a method: function object:method (...) ... end
  • Tables

    Object Root object


    Tables

    Object
    Root object

    Fields

    • _init: list of fields to be initialised by the constructor: assuming the default _clone, the numbered values in an object constructor are assigned to the fields given in _init
    • _clone: object constructor which takes initial values for fields in _init

Valid XHTML 1.0!