SLStack
SLStack is a concrete, string-valued LIFO stack in the SLeeLa collections
library, backed by the VM-managed growable native array. It requires no
Generics and no new VM opcodes.
Naming note: a different class named
SLStackalso exists in thecpufamily — that one is the hardware call/data stack (stack pointer, base/limit, overflow/underflow faults). The spec assigns the bare nameSLStackto the collections family. When a program could reach both, addimport collections;(orimport cpu;) to select the intended one; a plain single-segment package import is honored as a preferred resolution root.
Operations
push(String value)/add(String value): push onto the top.peek(): top value without removing it;nullwhen empty.pop(): remove and return the top value;nullwhen empty.remove(): discard the top item, if present.clear(): drop every item while retaining backing-array capacity.length()/empty(): query stack height / emptiness.
Backing-array capacity freed by pop/remove is reused by later push
calls. This first version accepts Strings only.
Example
See SLStackBasic.