Repository navigation
Propose declaring the machine a conversion read - #627
Merged
Merged
Conversation
`convert` answers with the machine it read a file as, beside the source and never in it, so every caller that hands the text on has to carry the answer alongside it or ask again. Propose an opt-in reading whose source opens with a `#MACHINE` line, spelled by the module that already recognises and strips one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NmQqDmxr5ULCtbGmzT3tYc
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.
Why
convertreads a machine's own program file back into BASIC and answers with the machine it read it as — beside the source, never in it. That is right for a caller writing the text to a file it has just named, and wrong for every caller that hands the text on to something which will have to ask the question again.An editor opening a freshly converted program has a listing whose machine has just been established beyond doubt and no way to tell, so it falls back on whatever it was configured for, and reports a
.prgagainst a ZX81. The listing already has a way to say this —#MACHINE, one physical line that costs no bytes and beats every other way of settling the question. Nothing stops a caller writing that line itself, and every caller that does is a second opinion about a machine the toolchain had already identified.What changes
convertcan be asked to declare the machine it read. When asked, the source it answers with opens with a#MACHINEline naming that machine, so the text alone is enough to reopen, check, build or run the program as what it is. The command line gains the matching flag.Off by default.
convert's source goes to standard output when no output path is given, and a caller piping that into something else would find an extra first line appear under it. So the declaration is asked for, and the default answer stays byte-for-byte what it is today.The writing half goes in
src/dialects/machineDirective.ts, which already owns recognising, parsing and stripping the directive, imports nothing but a type, and knows about no dialect and no registry. It has no writing half today. Building the line anywhere else would put the two halves of one syntax in two places, and the first divergence would be silent: a lineconvertwrote thatreadMachineDirectivedoes not read back.No route is added or removed, so
src/ops/parity.tsis untouched and no caller gains or loses an exemption. No impact on theDialect/MachineEmulatorseam — the operation already knows the dialect it resolved, and the id it declares is the one it resolved to.One fact worth a test
A
#MACHINEline is stripped before a listing is tokenized, so no directive can survive into a machine's binary and come back out of a detokenizer. The recovered source therefore never already carries one, and the prepend never has to look for an existing line. That is a property of the whole pipeline rather than of either end, which is why the tasks pin it with a test rather than a comment.Who this is for
The agent and the command line as much as an editor: any caller that converts a file and then does anything else with the text would otherwise have to carry the machine alongside it. The immediate consumer is the VS Code client's import command — seanhodges/basically-editor-extensions,
import-a-machine-file-as-a-listing— which opens the recovered listing in an editor where nothing else can answer the question. That change rests on this one and says so.Not done
This is the proposal only — no implementation, no tests run beyond
openspec validate.openspec/changes/declare-the-machine-in-a-converted-program/holds the proposal, design, spec delta and tasks; every task is unchecked.Spec
Delta on
headless-cli, the requirement A machine's binary program file can be read back as BASIC, which gains the option of a reading that says in the source itself which machine it was read as — and the guarantee that a caller who does not ask gets exactly what it gets today.openspec validatepasses on the change, andvalidate --specson all 22 baseline specs.🤖 Generated with Claude Code
https://claude.ai/code/session_01NmQqDmxr5ULCtbGmzT3tYc
Generated by Claude Code