Building output text is the write-side mirror of reading input text.

output buffer A small string buffer makes write-style examples deterministic for static replay.

Buffer Append

word
buffer_append.lua
Replay: real traced execution (multi-file project)
local word = "trace"
local buffer = "start"

buffer = buffer .. ":" .. word
buffer = buffer .. ":done"

print("word=" .. word)
print("buffer=" .. buffer)
local word = "replay"
local buffer = "start"

buffer = buffer .. ":" .. word
buffer = buffer .. ":done"

print("word=" .. word)
print("buffer=" .. buffer)
local word = "lesson"
local buffer = "start"

buffer = buffer .. ":" .. word
buffer = buffer .. ":done"

print("word=" .. word)
print("buffer=" .. buffer)
  1. word ← trace, buffer ← start

    1local word→ trace = "trace" --@word="replay", "lesson"2local buffer→ start = "start"34buffer→ start:trace = buffer .. ":" .. wordtrace5buffer→ start:trace:done = buffer .. ":done"67print("word=" .. wordtrace)8print("buffer=" .. bufferstart:trace:done)
    outputword=trace
    buffer=start:trace:done
  1. word ← replay, buffer ← start

    1local word→ replay = "replay"2local buffer→ start = "start"34buffer→ start:replay = buffer .. ":" .. wordreplay5buffer→ start:replay:done = buffer .. ":done"67print("word=" .. wordreplay)8print("buffer=" .. bufferstart:replay:done)
    outputword=replay
    buffer=start:replay:done
  1. word ← lesson, buffer ← start

    1local word→ lesson = "lesson"2local buffer→ start = "start"34buffer→ start:lesson = buffer .. ":" .. wordlesson5buffer→ start:lesson:done = buffer .. ":done"67print("word=" .. wordlesson)8print("buffer=" .. bufferstart:lesson:done)
    outputword=lesson
    buffer=start:lesson:done