-- examples/reflect.cat -- reflection: attributes() and help(). -- -- `attributes(obj)` lists an object's members (like Python's dir()), -- following inheritance via `__index`. `help(obj)` prints an object's -- documentation, read from its `_doc_` attribute. local point = {x = 0, y = 0, name = "origin"} point._doc_ = "A 2D point with x, y coordinates." print("point attrs:", len(attributes(point))) for a in attributes(point) do print(" -", a) end class Animal function speak(self) print("...") end function name(self) return "animal" end end local a = Animal() print("animal has speak:", len(attributes(a)) > 0) print("--- help(point) ---") help(point) print("--- help(print) ---") help(print)