The language is OOP with a single compound value, the object (an
anonymous `{...}` or a class instance); it is not Lua and has no
"tables". The visible type name was already `object`; this fixes the
remaining user-facing wording:
- error messages: "object has no member 'x'", "object is not callable".
- README: drop the "Lua-like" phrasing; describe member objects, not
tables.
- self-hosted front-end AST node `t="object"` (was "table"), updated
across parser/compiler/checker.
- test comments/expected output aligned ("object:").
The internal C symbols keep the cat_types_table_* naming convention.
Suite stays 130 green.
19 lines
562 B
Plaintext
19 lines
562 B
Plaintext
-- tests/module.cat -- the `module` global reflects the current unit.
|
|
--
|
|
-- `module` is a global object: `name` is the basename of the running
|
|
-- file, `path` its path and `dir` its directory. Importing another
|
|
-- file (use/dofile) swaps `module` for the duration of that file and
|
|
-- restores the caller's afterwards.
|
|
|
|
print("name:", module.name)
|
|
print("dir:", module.dir)
|
|
|
|
-- a user may mutate it like any object
|
|
module.extra = "tagged"
|
|
print("extra:", module.extra)
|
|
|
|
use("tests/module_lib.cat")
|
|
|
|
print("back:", module.name)
|
|
print("extra kept:", module.extra)
|