Repository navigation
seed and tape Perl and Lua ports - #44
Merged
Merged
Conversation
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
force-pushed
the
feat/perl-and-lua-runners
branch
from
September 8, 2026 11:21
8a02868 to
4b95b99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
PERL5OPT=-I<dir> -Mprescriptrand,srandLUA_INIT=@<file>math.random,math.randomseedPerl's shim has to load before the program is compiled. That is not a preference: a call to
randconsults*CORE::GLOBAL::randat the point it is compiled, so an override installed any later is never seen. The same rule bites inside the module — a module's ownmydeclarations run after itsBEGINblock, so the state the override closes over is held in package variables initialised insideBEGIN.Lua's
math.randomandmath.randomseedare 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
seededRunnersandtapedRunners, and all three modes were exercised by hand as well:170 749 96, taped973 411 47with a usage count of 3, and a tape one value short exits non-zero withthe tape ran out after 2 values.246 234 69, taped973 411 47with 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 formatandmake docker_testall pass; the container run hasPRESCRIPT_REQUIRE_RUNNERS=1set, so perl and lua ran there rather than skipping.Image
luais not indebian:bookworm-slim, so the image installslua5.4, whose Debian package registers/usr/bin/luathrough alternatives — the namerunners/lua.yamlstarts, so no symlink is needed.perlis already present. CI installslua5.4to match.$PRESCRIPT_ENVIRONMENTnow reports both, and the listing indocs/container.mdwas 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