- 신선한 탐사자(fable) 단일 컨텍스트, 지시서 -round10-brief.md §2 레인 A·C 완료, B 부분, D ALL PASS - audit/handtrace-round10-reference-impl/: round7 참조 구현을 현재 계약으로 갱신·재실행 (부수: round7/ref9 _recompute 첫 인자 오류 발견·정정) - base/·인덱스 레이어는 미변경 — 결정은 사용자 배치 회신 뒤 -round10-followup.md로 Co-authored-by: qwreey <me@qwreey.moe> Claude-Session: https://claude.ai/code/session_01546hjsYNLSMZdHdPyTZaGb
20 lines
856 B
Text
20 lines
856 B
Text
--!nocheck
|
|
local q = require("./core")
|
|
-- 갈래 (b): rawInvalid를 fn 호출 *전에* 내리고, 도중에 다시 세워졌으면 그대로 둔다
|
|
local State = getmetatable(q.State(function() end, {}))
|
|
State._recompute = function(self)
|
|
self.recomputes += 1
|
|
self.rawInvalid = false -- ← 먼저 내린다
|
|
self.cache = self.fn(self, self.cache, table.unpack(self.deps))
|
|
for _, d in self.deps do d:_track(self.valueEpochMap) end
|
|
-- rawInvalid가 fn 도중 다시 true가 됐으면 그대로 둔다(덮어쓰지 않는다)
|
|
end
|
|
local A = q.Source(1)
|
|
local D = q.State(function(self, prev, a)
|
|
local v = a:Get()
|
|
if v == 1 then A:Set(99) end
|
|
return v * 2
|
|
end, {A}, "D")
|
|
print("D:Get() =", D:Get())
|
|
print("다시 D:Get() =", D:Get(), " ← 198이면 고쳐진 것")
|
|
print("재계산 횟수:", D.recomputes)
|