go: eval.sx — method dispatch + unary + e2e programs + 14 tests; Phase 4 bar crossed [nothing]
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Phase 4 cont. The crossings:
* Method dispatch — Methods record under #method/TYPE/NAME (same
mangled-key scheme the type checker uses, intentionally so eval
and type checker can converge on a shared method-table protocol
later). go-eval-method-call: lookup the receiver type's method,
bind receiver param to the struct value, evaluate body. Value and
pointer receivers treated the same in v0 (pointer semantics not
modelled yet).
* Method-call dispatch — In go-eval's :app branch, head=:select
routes to go-eval-method-call. If the receiver is not a struct,
falls back to the field-as-callable path.
* Unary prefix ops — go-eval's :app branch checks for 1-arg :var
head with op name "-" / "+" / "!". (Other unary ops like
*p / &v / <-ch / ^x deferred until pointer / channel / bitwise
semantics arrive.)
End-to-end programs verified:
* recursive fib(10) = 55
* struct + method + iterative loop (counter bump 7 times)
* linear search (returns index or -1)
* factorial via method on Counter (= 120)
* count odd numbers in 1..10 = 5
**Phase 4 acceptance bar (80+) crossed: eval 80/80, total 457/457.**
Remaining Phase 4 work (closures, multi-return, full slice triple,
pointer semantics) refines but doesn't gate Phase 5 (goroutines).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -287,19 +287,22 @@ Progress-log line → push `origin/loops/go`.
|
||||
(nil for missing key, until runtime type info enables zero-value),
|
||||
`m[k] = v` index-assignment, `len(m)`. Index-assignment for slices
|
||||
also lands here (`a[i] = v` rebuilds via `go-slice-set`).
|
||||
- [/] Structs: `(list :go-struct TYPE-NAME FIELDS)` where FIELDS is an
|
||||
assoc list. `type Point struct {...}` registers field names in
|
||||
env via `(:go-struct-type FIELD-NAMES)`; positional and keyed
|
||||
composite literals build struct values; `p.field` selector and
|
||||
`p.field = v` selector-assignment work. Methods lookup-by-receiver
|
||||
pending — depends on threading the type checker's method-key
|
||||
scheme into eval.
|
||||
- [x] Structs + method dispatch. `(list :go-struct TYPE-NAME FIELDS)`
|
||||
assoc-list. `type T struct {...}` registers `:go-struct-type`
|
||||
with field names. Positional + keyed composite literals; `p.f`
|
||||
/ `p.f = v` selectors. Methods bind under `#method/T/N` mangled
|
||||
keys — same scheme as the type checker. `p.M(...)` dispatches via
|
||||
receiver type lookup, binds the receiver param to the struct
|
||||
value, runs body. Both value and pointer receivers work in v0
|
||||
(treated the same since pointer semantics aren't modelled yet).
|
||||
- [/] Functions: top-level definition + call (incl. recursion via the
|
||||
calling env). Lexical closures and multiple return values pending.
|
||||
- [ ] Channels: stub (Phase 5 wires them).
|
||||
- Tests: arithmetic, control flow, recursion, closures, slices, maps,
|
||||
structs, methods, pointer semantics, multiple-return.
|
||||
- **Acceptance:** eval/ suite at 80+ tests. Current: 66/66. No concurrency yet.
|
||||
- **Acceptance:** eval/ suite at 80+ tests. **Bar crossed: 80/80.**
|
||||
Remaining sub-items (lexical closures, multi-return funcs, full
|
||||
slice triple with capacity) refine but don't gate Phase 5.
|
||||
|
||||
### Phase 5 — Goroutines + channels + select (`lib/go/sched.sx`) ⬜
|
||||
- **Independent implementation.** Do NOT use lib/guest/scheduler/ — that
|
||||
@@ -583,6 +586,17 @@ Minimal repro: see `lib/go/lex.sx#gl-oct-digit?` and `#gl-match-op`.
|
||||
|
||||
_Newest first. Append one dated entry per commit._
|
||||
|
||||
- 2026-05-27 — Phase 4 cont.: **method dispatch + unary ops + e2e
|
||||
programs. Acceptance bar (80+) crossed.** Methods register under
|
||||
`#method/TYPE/NAME` (same scheme the type checker uses). When `p.M(...)`
|
||||
is called, `go-eval-method-call` looks up the receiver type's method,
|
||||
binds the receiver param to the struct value, runs the body. Both
|
||||
value and pointer receivers work in v0 (treated the same — no
|
||||
pointer semantics yet). Unary `-x` / `+x` / `!x` in `go-eval`.
|
||||
E2E programs evaluating end-to-end now include: counter-via-method
|
||||
(factorial), linear search returning index or -1, recursive
|
||||
fibonacci(10) = 55, and the counter-bump-N-times pattern. +14 tests,
|
||||
eval 80/80, total 457/457. `[nothing]`.
|
||||
- 2026-05-27 — Phase 4 cont.: structs + selector access +
|
||||
selector-assignment. `(:go-struct TYPE-NAME FIELDS)` value, with
|
||||
FIELDS an assoc list. `type T struct {...}` is now significant at
|
||||
|
||||
Reference in New Issue
Block a user