Skip to content

seed and tape Perl and Lua ports - #44

Merged
rjnienaber merged 1 commit into
mainfrom
feat/perl-and-lua-runners
Sep 8, 2026
Merged

rjnienaber merged 1 commit into
mainfrom
feat/perl-and-lua-runners

Conversation

@rjnienaber

@rjnienaber rjnienaber commented Sep 8, 2026 •

Copy link
Copy Markdown
Owner

Follows #43, now merged; rebased onto main so this branch is only the two new runners.

Perl is the largest remaining gap in coding-horror/basic-computer-games: 75 ports, more than any language the shipped runners did not already cover. Lua is smaller but comes almost free, and both hook the same way — an environment variable naming a file the interpreter runs before the program.

How each one is reached

Language Mechanism Replaces Tape
Perl PERL5OPT=-I<dir> -Mprescript rand, srand yes
Lua LUA_INIT=@<file> math.random, math.randomseed yes

Perl's shim has to load before the program is compiled. That is not a preference: a call to rand consults *CORE::GLOBAL::rand at the point it is compiled, so an override installed any later is never seen. The same rule bites inside the module — a module's own my declarations run after its BEGIN block, so the state the override closes over is held in package variables initialised inside BEGIN.

Lua's math.random and math.randomseed are ordinary table fields, so the tape path replaces both outright.

Both follow the existing house rule: a tape replaces the draw function and neutralises the seeding function, while seeded mode only seeds the language's own generator and leaves a port's own reseed alone.

Verification

Both runners are in seededRunners and tapedRunners, and all three modes were exercised by hand as well:

  • Perl — seeded 170 749 96, taped 973 411 47 with a usage count of 3, and a tape one value short exits non-zero with the tape ran out after 2 values.
  • Lua — seeded 246 234 69, taped 973 411 47 with a usage count of 3, off-the-end exits 1; unseeded gives different numbers each run, so the shim is load-bearing rather than decorative.

The seeded rows are each language's own generator — drand48 for Perl, the xoshiro256** Lua has used since 5.4 — and were checked across two versions each (perl 5.34 and 5.36; lua 5.4 and 5.5, which agree) rather than snapshotted from one machine, so the container and a developer's host give the same numbers.

make lint, PRESCRIPT_REQUIRE_RUNNERS=1 make test, make build_dev, make examples, make format and make docker_test all pass; the container run has PRESCRIPT_REQUIRE_RUNNERS=1 set, so perl and lua ran there rather than skipping.

Image

lua is not in debian:bookworm-slim, so the image installs lua5.4, whose Debian package registers /usr/bin/lua through alternatives — the name runners/lua.yaml starts, so no symlink is needed. perl is already present. CI installs lua5.4 to match. $PRESCRIPT_ENVIRONMENT now reports both, and the listing in docs/container.md was diffed against the rebuilt image.

Docs

docs/determinism.md's "not yet shipped" table now also names the three near misses the corpus survey turned up — Kotlin (already JVM bytecode, a line in the agent's owner list away), VB.NET, and MiniScript (the largest single set of ports, and the only one with no launch hook at all).

🤖 Generated with Claude Code

https://claude.ai/code/session_019f9gkZVUEo3jtv51GSb4vJ

Base automatically changed from feat/jvm-and-dotnet-runners to main September 8, 2026 10:27
Perl is the largest gap in the corpus after the JVM and .NET work: 75
ports, more than any language the shipped runners did not already cover.
Lua is smaller but comes almost free, and both hook the same way -- an
environment variable naming a file the interpreter runs before the
program.

Perl's shim arrives through PERL5OPT=-M, which loads it before the
program is compiled. That ordering is not a preference: a call to `rand`
consults *CORE::GLOBAL::rand when it is compiled, so an override
installed any later is not seen. The same rule applies inside the module
-- its own `my` declarations run after its BEGIN block, so the state the
override closes over is held in package variables initialised in BEGIN.

Lua's arrives through LUA_INIT=@file. math.random and math.randomseed
are ordinary table fields, so the tape path replaces both outright.

Both follow the house rule: a tape replaces the draw function and
neutralises the seeding function, while seeded mode only seeds the
language's own generator and leaves a port's own reseed alone. The
seeded rows in the test are each language's own generator -- drand48 for
Perl, xoshiro256** for Lua -- checked across two versions rather than
taken from one machine, so the container and a developer's host agree.

Lua is not in debian:bookworm-slim, so the image now installs lua5.4,
whose package registers /usr/bin/lua through alternatives; perl is
already there. CI installs lua5.4 to match.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019f9gkZVUEo3jtv51GSb4vJ
@rjnienaber
rjnienaber force-pushed the feat/perl-and-lua-runners branch from 8a02868 to 4b95b99 Compare September 8, 2026 11:21
@rjnienaber
rjnienaber merged commit 8af0a06 into main Sep 8, 2026
5 checks passed
@rjnienaber
rjnienaber deleted the feat/perl-and-lua-runners branch September 8, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant