Helpers for building interface-style wrappers and concrete implementations over named method descriptions.


Model

Method descriptions name parameters and results. interface turns them into a vtable of Code values and an interface base object of forwarding members.

implement turns an interface-base supplier (@Mover) and a concrete-object supplier into a factory; its CALL constructs concrete objects containing base and the supplied fields.

obj.base is the borrowed interface view accepted where the interface is expected.

The factory owns the vtable; keep it alive and unmoved while its objects or views use it.


interface

(getMethods -- interfaceFactory) Builds a callable factory from a method-description supplier.

Generated interface shape

Method-description grammar

Generated fields

Interface factory

Vtable

Interface base


implement

(getBase getObject -- implementationFactory) Builds a callable implementation factory using an interface-base supplier and a concrete-object supplier.

Remarks


Generated implementation shape

Implementation factory

Concrete object and base adapter

Result and view rules

Implementation lifetime

Validation and reserved names


Examples

Generated implementation call

"String"    use
"control"   use
"interface" use

Mover: [{move: {value: Int32; result: Int32;};}] interface;
MoverImpl: @Mover [{
  move: {value: Int32;} Int32 {} codeRef;
  [1 +] !move
}] implement;

{base: Mover Cref;} Int32 {} [
  base:;
  41 base.move
] "useMover" exportFunction

{} Int32 {} [
  obj: MoverImpl;
  ("direct: " 41 obj.base.move LF) printList
  ("through a Mover Cref: " obj.base useMover LF) printList
  0
] "main" exportFunction

Expected Output

direct: 42
through a Mover Cref: 42

Method as a Block reading a concrete field

"String"    use
"control"   use
"interface" use

Adder: [{add: {amount: Int32; result: Int32;};}] interface;
AdderImpl: @Adder [{
  baseValue: 10;
  add: [baseValue +];
}] implement;

{} Int32 {} [
  object: AdderImpl;
  ("result=" 41 @object.base.add LF) printList
  0
] "main" exportFunction

Expected Output

result=51

Internal helper

cloneField

(ordinal object -- fieldValue) Returns a field-schema object for a known Int32 ordinal.
  • A stored reference produces the corresponding NIL reference form, preserving its view's constness.
  • Other fields produce a new variable of the same schema; their current runtime values are not copied. Meta fields retain their Meta form.
  • This operation is for generated signatures, not for cloning object data.

See also