Statement macro
Allocates an object within the scope of the body of the code.
with-stack-structure (name :: wrapper-type
#key element-count extra-bytes)
body
end [with-stack-structure]
<integer>.
<integer>.
c-ffi
c-ffi
Allocates an object name within the scope of a body. The element-count and extra-bytes options behave as in make. The memory that was allocated is freed after body exits.
This macro gives the object dynamic extent.
? define C-struct <PointStruct>
slot x-coord :: <C-unsigned-short>;
slot y-coord :: <C-unsigned-short>;
pointer-type-name: <PointStruct*>
end C-struct;
// Defined <PointStruct>, x-coord, x-coord-setter,
// y-coord, and y-coord-setter.
? define constant <Point> = <PointStruct*>;
// Defined <Point>.
? define C-function PlotPoint
parameter point :: <Point>;
c-name: "PlotPoint";
end C-function;
// Defined PlotPoint.
? define method plot (x, y)
with-stack-structure (point :: <Point>)
point.x-coord := 20;
point.y-coord := 30;
PlotPoint(point);
end;
end;
// Defined plot.
? plot(20, 20);
? plot(50, 50);