- VM refactor: resumable CAT_VM_Frame (ip/sp/locals/handlers) - yield/next/generators: calling a yield-function returns a generator - for..in over any iterator, ends on explicit exhaustion status - raise/try/except: structured error values, nearest-handler unwinding - slots: C-declared member layout (offsetof), PyTypeObject/tp_members style - File now exposes path/mode/closed via slots - examples: generators.cat, errors.cat, slots.cat; 40/40 tests
15 lines
518 B
Plaintext
15 lines
518 B
Plaintext
-- examples/slots.cat -- the slot-based object layout.
|
|
--
|
|
-- A C module declares its concrete layout once (a fixed array of
|
|
-- CAT_VALUE_Slot). The attribute dispatcher then reads members by
|
|
-- offset, so `f.path` / `f.mode` / `f.closed` need no per-attribute C
|
|
-- code. This is the analogue of CPython's tp_members / __slots__.
|
|
|
|
local f = File::open("/tmp/catscript_slots_demo.txt", "w")
|
|
print("path:", f.path)
|
|
print("mode:", f.mode)
|
|
print("closed:", f.closed)
|
|
f:write("slots")
|
|
f:close()
|
|
print("closed:", f.closed)
|