Raw object layer: construction, slot and metadata access, FFI handles, on the Obj class.
ns
objis de-registered – no bare names; boot/hot callers fetch from the catalogue.
Obj(Obj make ts n)Allocate a raw typed object with N nil slots (the Vector pattern: slot 0 = length).
GC CONTRACT: raw slots are traced only if the TYPE declares units – ((prim-ref ‘type ‘set-units!) ts -1) for slot-0-counted sizes (the Vector convention), or a fixed count. Without it a collect frees the payloads under the object (otherwise the segfault a Dict hits across a REPL turn).
Parameters:
ANY — Type handle (from Type of / make-type)INTEGER — Number of slotsReturns: ANY — The new object
Examples:
(let ((o (Obj make (Type of (Vector make 2 ())) 3))) (Obj set! o 1 42) (Obj ref o 1)) => 42(Obj ref obj i)Read slot I of a raw object.
Parameters:
ANY — ObjectINTEGER — Slot index (0-based)Returns: ANY — The slot value
Examples:
(Obj ref (pair 'a 'b) 1) => 'b(Obj set! obj i v)Write slot I of a raw object.
Parameters:
ANY — ObjectINTEGER — Slot index (0-based)ANY — Value to storeReturns: ANY — nil
Examples:
(let ((p (pair 1 2))) (Obj set! p 1 9) p) => (1 . 9)(Obj ->ptr obj)The raw pointer of an object (FFI handle; see also Ptr).
Parameters:
ANY — ObjectReturns: ANY — A PTR to the object’s storage
Examples:
(Ptr ptr? (Obj ->ptr (list 1 2))) => #t(Obj meta-count)The base-wide extra-metadata slot count (0 = metadata disabled).
Returns: INTEGER — Current extra-slot count
(Obj meta-count! n)Set the base-wide extra-metadata slot count; objects allocated afterwards carry N extra slots. BOOT-TIME POLICY: setting a width DIFFERENT from the current one while allocated objects are live is undefined – the engine frees each object’s prefix at the width current at COLLECT time, so older objects are freed at the wrong address (x-engine-c#21). Setting the value it already holds is safe.
Parameters:
INTEGER — Extra slots to reserve per objectReturns: INTEGER — The previous extra-slot count
(Obj meta-ref obj i)Read metadata slot I of an object (e.g. coverage flags, source line).
Parameters:
ANY — ObjectINTEGER — Metadata slot indexReturns: ANY — The metadata value
(Obj meta-set! obj i v)Write metadata slot I of an object.
Parameters:
ANY — ObjectINTEGER — Metadata slot indexANY — Value to storeReturns: ANY — nil
(Obj make-callable p)Wrap a C function pointer as a callable primitive object.
Parameters:
ANY — C function pointer (PTR, e.g. from the JIT or dlsym)Returns: CALLABLE — The new callable