Complete Dartmouth and Commodore disk operations #28
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
akbasic exposes part of the Dartmouth and Commodore disk vocabulary, but several commands are still refused or absent even where the host filesystem can provide a safe and deterministic equivalent.
At
c5d13f00f6fd2d6f4759d252b30165a533a1863e:src/runtime_disk.c:381-400refusesDIRECTORYandCATALOG.src/runtime_disk.c:697-738refusesHEADER,COLLECT,BACKUP, andBOOT.src/runtime_disk.c:265-376implements only the file forms ofSCRATCH,RENAME, andCOPY.src/runtime_commands.c:606-712givesDLOADandDSAVEno Dartmouth current-program-name contract.src/parser_commands.c:471-497requires a special spacedPRINT #spelling and has no BASIC 2.0OPEN,CLOSE,CMD, orGET#compatibility forms.docs/09-files-and-disk.md:125-141anddocs/13-differences.md:196-202document the missing surface.Functional consequence: programs written around either the Dartmouth timesharing workflow or Commodore disk channels need source changes, and directory traversal, recursive copies, and host boot requests cannot be expressed.
Blast radius: high. This touches parsing, runtime modes, public runtime state, host integration, filesystem behavior, compatibility documentation, and dependency APIs.
Inventory
Dartmouth treated these as DTSS operating-system commands around BASIC rather than statements inside a stored program. They are still part of the requested interactive BASIC workflow:
NEW [name]OLD nameSAVE [name]REPLACE [name]RENAME nameCATandCATALOGUNSAVE [name]SCRATCH, which clears the program in memoryThe Commodore BASIC 2.0 and 7.0 disk surface is:
APPEND,BLOAD,BSAVE,CONCAT,COPY,DLOADorLOAD,DSAVEorSAVE,DVERIFYorVERIFY,RECORD,RENAME,SCRATCH, andRUN "filename"DOPEN,DCLOSE,OPEN,CLOSE,CMD,GET#,INPUT#, andPRINT#CATALOG,DIRECTORY,DCLEAR,COLLECT,HEADER, andBACKUPBOOTakbasic already implements
APPEND,BLOAD,BSAVE,CONCAT, file-onlyCOPY,DCLEAR,DCLOSE,DLOADorLOAD,DOPEN,DSAVEorSAVE,DVERIFYorVERIFY,INPUT#,PRINT#,RECORD, file-pairRENAME, and fileSCRATCH.The remaining work is the Dartmouth name lifecycle, BASIC 2.0 channel aliases,
CMD,GET#,RUN "filename", directory listings, recursiveCOPY, the safeCOLLECTmapping, and the host-mediatedBOOTmapping.HEADERandBACKUPneed explicit final refusal contracts because a host directory is not a Commodore disk.Behavioral contract
Paths and drives
D0,U8, andON U8, but accept only drive 0 and unit 8. Refuse every other drive or device withAKBASIC_ERR_DEVICE.Dartmouth program names
Store a bounded current-program path on
akbasic_Runtime.NEW ["name"]clears the program and optionally sets its current name.OLD nameloads the named program and makes that path current.SAVE [name]writes the named or current program and refuses to overwrite an existing file.REPLACE [name]writes the named or current program and permits replacement.UNSAVE [name]removes the stored copy without changing the program in memory.RENAME namechanges only the current program name.SCRATCHclears the program while retaining the current name.SCRATCH "path"remains the Commodore file-delete form.RENAME "old","new"; also accept the exact Commodore formRENAME "old" TO "new".DSAVEas the explicit overwrite-capable Commodore save operation.Directory and copy operations
Implement
DIRECTORY,CATALOG, andCATthrough one backend:/.*and?.Extend
COPYto copy complete directory trees:BACKUPalias unnecessary; keepBACKUPrefused as a physical-disk operation.BASIC 2.0 channels
OPENsupports disk device 8 only and maps its logical file and mode onto the existing bounded channel table. Refuse non-disk devices.CLOSEmaps toDCLOSE.CMDredirects ordinaryPRINToutput to an open channel until an emptyPRINT#or closure of that channel.GET#reads one character at a time.STandST#status values and update them for successful reads and EOF.INPUT#as line-oriented input.PRINT#,INPUT#, andGET#without requiring a space before#.Media commands
COLLECTis a successful no-op after validating that only the default drive and unit were requested. A host filesystem owns its allocation metadata.HEADERremains anAKBASIC_ERR_DEVICErefusal and must never delete or format a directory.BACKUPremains anAKBASIC_ERR_DEVICErefusal and must never infer a physical-disk operation from host paths.RUN and BOOT
RUN "filename"clears the current program, loads the file, records it as current, and runs it.BOOTonly as an unnumbered direct REPL command..bastarget performsNEW,DLOAD, andRUN.AKBASIC_MODE_BOOT.akbasic_runtime_take_boot_request()so an embedding host can consume the request.execvand one filename. Never use a shell and never accept embedded argument text.BOOTstatements.Dependency work
Do not bypass libakstdlib with direct platform calls. Complete and release the dependency APIs first, then update the pinned submodule:
This issue stays blocked until those interfaces are available in a released libakstdlib revision.
Implementation order
#verbs,TO, drive and unit selectors, and Dartmouth bare names.RUN "filename".COPY.OPEN,CLOSE,CMD,GET#,ST, andST#.BOOT, the validatedCOLLECTno-op, and permanent destructive-command refusals.Acceptance tests
Add executable tests for:
UNSAVE.SAVEversusREPLACEandDSAVE.SCRATCHmeanings.OPEN,CLOSE,CMD, compact channel spellings, character-at-a-timeGET#, and EOF status.RUN "filename", BASICBOOT, external boot requests, embedded-host consumption, REPL-only enforcement, and direct one-path process invocation.HEADERandBACKUPproving that no filesystem mutation occurred.Run both supported build configurations, the complete CTest suite, ASan and UBSan, coverage, and focused mutation testing for parser branches, recursive cleanup, channel state, and boot-mode transitions.
References
Tachikoma (Codex GPT-5, context window size not exposed)