Tab lists its matches in columns, and says what it can in colour
Tab's listing was six instructions: print the name, print two spaces. It was the crown of this shell for a while and looks plain next to ls. Columns cost NOTHING EXTRA. Tab already walks its candidates twice - once to find the answer, once to show the matches, and tabRunSources exists because those are the same walk asked two questions. The longest match is counted on the first, which already visits every one of them, so the listing needs no walk of its own to know how wide a column should be. Padding goes before a name rather than after, so a row ends on a name. Directories are blue and the shell's own commands are green. Both are free: Tab appends the separator itself, and a built-in is not a file at all - which is also the only way anybody could know it will run. A FILE IS NOT COLOURED, and that is a decision. Whether a file will run is a read of its first block, which is what ls does and what makes ls cost twice what it otherwise would. Here it would be worse than slow: candidates are offered from inside a directory walk, and looking a file up would overwrite the very fields holding the walk's own position. Doing it safely means holding every candidate name in memory, which is a buffer the shell would carry whether anybody pressed Tab or not - and ls is one keystroke away. A Tab press already costs about 200,000 cycles, so the read was not the objection. ---- And the machine could no longer build itself ---- Found by make test, not by reading. The native assembler ran out of room for label names on cosmos.asm: 16,758 bytes against 16,384. The index was 1,341 of 1,536 in the same breath. Which is scratch.asm's own warning happening a second time - "two ceilings a hundred bytes apart look like one ceiling until the first is lifted" - so both were raised, out of the seventeen kilobyte page that file deliberately left unclaimed against exactly this. Names to 26,624 and the index to 2,048, both left about a third clear, with 1,792 bytes still unclaimed for the same reason. A name is thirteen bytes on average and an index entry is four, so the arena will always be the one that speaks first. That is now written down where the two numbers are. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
eaeb473176
commit
563bc20a75
@@ -297,18 +297,21 @@ LabEnd:
|
||||
; How many labels there may be, and how many bytes of name between them.
|
||||
;
|
||||
; SIZED FOR THE ASSEMBLER ITSELF, which turns out to be the largest thing it is asked to
|
||||
; build: 555 labels and about 6,800 bytes of name, against CosmOS's 650 and 8,081 - CosmOS is
|
||||
; the bigger of the two now, and was the smaller when this was written. Running into either
|
||||
; build: the assembler is about 555 labels, against CosmOS's 1,341 and 16,758 bytes of name
|
||||
; measured 2026-09-06 - CosmOS is much the bigger of the two now, and was the smaller when
|
||||
; this was written. Running into either
|
||||
; limit says so rather than writing past the end of the table, and that is what it did. The buffers live
|
||||
; above the program rather than inside it - see the scratch map in Asm.asm.
|
||||
; Fifteen hundred and thirty six names, and sixteen kilobytes to hold them in. Both were
|
||||
; half that, and the names ran out first: 8,081 bytes of 8,192, which is a hundred and
|
||||
; eleven - and the thing that ran into it was one ordinary piece of work adding eighteen
|
||||
; labels. THESE TWO MUST AGREE WITH THE SCRATCH MAP, which says where the room actually is.
|
||||
; Two thousand and forty eight names, and twenty six kilobytes to hold them in. Both have
|
||||
; now been doubled twice, and BOTH TIMES THE NAMES RAN OUT FIRST with the index a couple of
|
||||
; hundred behind them - 8,081 of 8,192 the first time, 16,758 of 16,384 the second. A name
|
||||
; is thirteen bytes on average and an index entry is four, so the arena will always be the
|
||||
; one that speaks; raising it alone would buy a few hundred labels and then the other wall.
|
||||
; THESE TWO MUST AGREE WITH THE SCRATCH MAP, which says where the room actually is.
|
||||
LabLimit:
|
||||
0x06 0x00
|
||||
0x08 0x00
|
||||
LabRoom:
|
||||
0x40 0x00
|
||||
0x68 0x00
|
||||
|
||||
LabNamed:
|
||||
": "
|
||||
|
||||
Reference in New Issue
Block a user