encoding: with Encode by value (ENCODING slice 7) #712

Open
opened 2026-11-07 22:38:41 +00:00 by orion · 1 comment
Collaborator

Context

docs/design/ENCODING.md, section 14, the table of slices: "7 with Encode by value | open - by delegation is built natively, but not for a member with a var parameter, which encode is (point 4 of 'What the checker and the back end must support')". Point 4 of that list: "Delegation of a method that takes a var parameter must forward the path and not a copy." The introduction (line 5) also names slice 7 as open. No issue tracks it.

Source

  • ENCODING.md section 7, point 4, and section 14, slice 7.
  • The by value wrapper the record uses for well-known types (Instant, Email, around lines 348, 570 and 696).

Goal

A single-field type writes with Encode by value (and Describe by value) and encodes as its one value, with the type's name kept for the formats that map it.

Acceptance criteria

  • by delegation forwards a var parameter as the path, not a copy, in the VM and the native back end; a conformance program shows a write through the delegated member reaching the caller's value
  • type Email with Encode by value from ENCODING.md type checks and encodes through std/json as the bare string
  • Decode by value behaves as the record says (line 712) and a type with an invariant is told to write decode
  • ENCODING.md slice 7 says Done, and the introduction no longer calls it open

Dependencies

None known.

Seed

Refine decides; likely no, unless the standard library or the compiler's own source adopts by value in the same round (then two commits with the seed between).

Size

One PR, one or two Conventional Commits (feat(checker)/feat(backend), test).

## Context [`docs/design/ENCODING.md`](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/ENCODING.md), section 14, the table of slices: "7 `with Encode by value` | **open** - `by` delegation is built natively, but not for a member with a `var` parameter, which `encode` is (point 4 of 'What the checker and the back end must support')". Point 4 of that list: "Delegation of a method that takes a `var` parameter must forward the path and not a copy." The introduction (line 5) also names slice 7 as open. No issue tracks it. ## Source - ENCODING.md section 7, point 4, and section 14, slice 7. - The `by value` wrapper the record uses for well-known types (`Instant`, `Email`, around lines 348, 570 and 696). ## Goal A single-field type writes `with Encode by value` (and `Describe by value`) and encodes as its one value, with the type's name kept for the formats that map it. ## Acceptance criteria - [ ] `by` delegation forwards a `var` parameter as the path, not a copy, in the VM and the native back end; a conformance program shows a write through the delegated member reaching the caller's value - [ ] `type Email with Encode by value` from ENCODING.md type checks and encodes through `std/json` as the bare string - [ ] `Decode by value` behaves as the record says (line 712) and a type with an invariant is told to write `decode` - [ ] ENCODING.md slice 7 says **Done**, and the introduction no longer calls it open ## Dependencies None known. ## Seed Refine decides; likely no, unless the standard library or the compiler's own source adopts `by value` in the same round (then two commits with the seed between). ## Size One PR, one or two Conventional Commits (`feat(checker)`/`feat(backend)`, `test`).
Author
Collaborator

[loop:torbscript] re-sweep: filed as homeless work: ENCODING.md section 14 marks slice 7 open and no issue tracked it. Label loop, no ready: refine checks the current delegation code against point 4 and confirms the seed statement.

[loop:torbscript] re-sweep: filed as homeless work: ENCODING.md section 14 marks slice 7 open and no issue tracked it. Label `loop`, no `ready`: refine checks the current delegation code against point 4 and confirms the seed statement.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#712
No description provided.