CONTAINER LAB — STACKS AND QUEUES
LearnSqueak native workshop • 17 October 2026

Requirements
Squeak 6.1, image build 23976, 64-bit. Morphic, OrderedCollection and SUnit
are bundled. No extra package, network request or JavaScript app is required.
Use a copy of your learning image. This kit does not include a VM or image.

Install and launch
1. In Squeak File List, select sources/stacks-queues-final.st and choose fileIn.
   A complete .st file uses chunk format; do not paste it into a Workspace.
2. In a Workspace, select this expression and Do it:
   LSContainerApp open
3. Close the window when finished. The app has no stepping registration or
   background process. You can also Inspect it to follow app -> model.

Checkpoint workflow
Each sources/stacks-queues-01.st through -08.st file is cumulative and
independently runnable in a clean Squeak image. Work forward, or use a fresh
baseline when returning to an earlier checkpoint. Filing in older source
does not remove methods introduced later. Close an old window before loading
another checkpoint. Exact launchers and highlighted methods are in
content/stacks-queues.json, and are shown on the workshop page.

01  Read two orders: two collections contain arrivals 1, 2, 3
02  Push / pop: add and remove at the stack top (nonempty precondition)
03  Enqueue / dequeue: add at rear, remove front (nonempty precondition)
04  Empty behavior: nil on empty removal; integer-only input
05  Native buttons: target/action controls and model/view separation
06  Bounded operation trace: six newest attempts; defensive history query
07  Capacity: validate before mutation; each container has independent room
08  Reset / load: preserve configuration, compare identical arrivals

Final contracts
- Integer payloads only, including zero, negatives and duplicates
- push: / enqueue: return true when accepted, false for invalid/full input
- pop / dequeue return the removed integer, or nil when empty
- Capacity is an integer from 1 to 6; shrinking below either size is rejected
- Failed operations preserve container contents, but record a trace event
- Reset clears both containers, trace and operation count; preserves capacity
- App Reset also restarts input numbering at 1
- Load 1 2 3 replaces both contents, records one event and sets next input to 4
- Loading at capacity below 3 is rejected without changing either collection
- Direct model changes through an Inspector need app refresh to update labels

Native SUnit
File in the final source, then sources/stacks-queues-tests.st.
Workspace -> Print it:
  LSContainerTest suite run
Expected: 42 passes, 0 failures, 0 errors.

Exercises
Try each exercise before viewing its solution. Then file in
sources/stacks-queues-exercise-1.st and stacks-queues-exercise-2.st, followed
by sources/stacks-queues-exercise-tests.st.
Workspace -> Print it:
  LSContainerExerciseTest suite run
Expected: 8 passes, 0 failures, 0 errors.
The first exercise peeks without side effects; the second validates both
preconditions before transferring one item from stack top to queue rear.

Reproduce verification and native captures
Python 3 is required; GIF encoding also requires Pillow. Supply the bundled
Squeak 6.1 VM and a clean Squeak 6.1 image. From this extracted kit directory:
  python scripts/run_native.py --vm /absolute/path/bin/squeak --image /absolute/path/clean.image --task all
Use --task stages, --task tests or --task gifs to run one part.
The runner copies the input image into runtime/Containers.image. It never
saves changes back to that image or the supplied original. Every invocation
loads the baseline afresh. Keep the corresponding SqueakV60.sources beside
the original image when available. The runner passes -vm-display-null and
-vm-sound-null, compiles the displayed snippets, executes exact launchers,
and saves real native window imageForm captures using PNGReadWriter.

Capture provenance
media/ has eight stage PNGs, a poster and a 22-frame GIF. frames/ retains
every native GIF input PNG. MouseButtonEvent mouseDown/mouseUp events drive
actual SimpleButtonMorph controls; state assertions verify the interaction
sequence. GIF durations are selected for readability (23.3 seconds total),
not a real-time screen recording. No UI was drawn outside Squeak.
results/ contains native test, checkpoint, GIF and integrity reports.

Implementation boundaries
The final model is limited to six integer values per container so all items
fit the native view. Earlier unbounded stages show the nearest six stack
items and first six queue items. This is a teaching application, not a
benchmark, generic collection library, concurrent queue or ring buffer.
The native classes are not installed in the site's embedded SqueakJS image.
