ADR 0145: Cascade Semantics for Immutable Values — Keep ; Fan-Out, Add a |> Pipeline

Status

Implemented (2026-11-10) — epic BT-4511 done: Phase 1 (BT-4512, BT-4513, BT-4573), Phase 2 (BT-4514, BT-4515), Phase 3 (BT-4516, BT-4517, BT-4518), Phase 4 (BT-4519). Accepted (2026-11-06); proposed 2026-11-05; amended 2026-11-09 (review: stage spans; the parser desugars |>, with a re-sugaring side table).

Decision record for the "Cascade Semantics" question that ADR 0042 deferred (to a planned "ADR 0044" that was never written — 0044 became comments-as-AST-nodes). Successor to the canceled research issue BT-506. Driving issue: BT-4352.

Context

The problem

A Smalltalk cascade sends every message to the same receiver and answers the last message's result:

Transcript show: "Hello"; cr; show: "World"
// ≡  Transcript show: "Hello".  Transcript cr.  Transcript show: "World"

That is the right meaning for anything whose messages act on the receiver in place — an actor (ADR 0042), a ClassBuilder (an Actor precisely so its cascade works, ADR 0038), an Ets table, the Transcript. It is the wrong meaning for an immutable value. A Value's with*: answers a new instance and leaves the receiver alone, so with the usual example value

Value subclass: Point
  field: x :: Integer = 0
  field: y :: Integer = 0
p := Point x: 1 y: 2
p withX: 5; withY: 10      // => Point(x: 1, y: 10) — the withX: result was dropped

withX:'s result is computed and discarded, and the cascade answers p withY: 10. Nothing warns. The same trap applies to every built-in value whose "update" messages answer a copy: Dictionary at:put:, List / String building messages, Integer max:, and every user Value subclass:.

Verified on main (2026-11-05) with a throwaway BUnit test: the cascade above answers Point(x: 1, y: 10); #{} at: #a put: 1; at: #b put: 2 answers a one-entry dictionary; and a TestCase whose setUp is self withA: 1; withB: 2 runs its tests with a = 0 — compiled without any warning.

ADR 0042 § Cascade Semantics recorded the problem and a leading candidate — cascade-as-pipeline on values (each message sent to the previous result, giving Elixir-style |> "for free") — but left three questions open:

  1. Type-dependent semantics — pipeline on values, fan-out on actors, or one uniform rule?
  2. Dynamic receivers — what happens when the receiver's kind is not known at compile time?
  3. ADR 0039 parity — cascades are listed under "What We Keep" (docs/beamtalk-syntax-rationale.md: Cascades — ✅ Same). Does a change argue its way past that?

Motivating example

beamtalk-buccaneer src/exchange.bt, upgradeToWebSocket:, threads four functional updates through an exchange-state value and stores the result:

self store: ((((st withWebsock: websock)
  withWebsockState: websock)
  withWebsocketOptions: opts)
  withRespState: #upgraded)

The reader has to count parentheses to see that this is a straight left-to-right chain. The obvious "cleanup" —

self store: (st withWebsock: websock; withWebsockState: websock;
  withWebsocketOptions: opts; withRespState: #upgraded)

— compiles, runs, and stores a state with only respState changed. Today the only readable correct alternative is a run of temp locals.

Current state

Constraints

Decision

Three parts, each independent enough to accept or reject on its own.

1. ; keeps uniform fan-out semantics for every receiver

A cascade always sends each message to the cascade target and answers the last message's result, whatever the target is — actor, value, Object instance, Erlang term or Dynamic. No change to the parser, codegen, runtime or type checker.

This settles ADR 0042's three questions:

QuestionAnswer
(1) Type-dependent semantics?No. One rule: ; is fan-out, everywhere.
(2) Dynamic receivers?Nothing to decide — the meaning of ; does not depend on the receiver's kind, so an unknown kind changes nothing. (The lint in part 3 is silent on them.)
(3) ADR 0039 parity?Preserved. ; means exactly what it means in Pharo/Squeak/Newspeak; pipeline chaining gets its own syntax instead of overloading a kept Smalltalk form.

2. A new pipeline operator |> chains messages on the previous result

statement-expr := keyword-expr                         // a plain send
                | keyword-expr ( ';'  message )+       // cascade (unchanged)
                | keyword-expr ( '|>' message )+       // pipeline (new)
message        := unary | keyword                      // a send without its receiver

A ; after a pipeline stage, or a |> after a cascade message, is the mixing error below. |> is one token only when the two characters are adjacent; | > stays Pipe followed by a binary >.

recv m1 |> m2 |> m3 sends m2 to the result of recv m1, and m3 to the result of that — it is exactly ((recv m1) m2) m3, and is defined by that rewrite. There is no new runtime behaviour, no type dependence, and it works the same on values, actors and Dynamic receivers.

The motivating example becomes:

self store: (st withWebsock: websock
  |> withWebsockState: websock
  |> withWebsocketOptions: opts
  |> withRespState: #upgraded)

Other shapes it reads well in:

// Collection pipelines (BT-506's original motivation)
total := orders select: [:o | o isPaid]
  |> collect: [:o | o amount]
  |> inject: 0 into: [:sum :a | sum + a]

// Building a value inside a block / HOM (ADR 0042's "sweet spot")
moved := points collect: [:p | p withX: 0 |> withY: p y + 1]

// Mixed unary and keyword stages
name := user profile |> at: #displayName |> trim

REPL:

> p := Point x: 1 y: 2
// => Point(x: 1, y: 2)
> p withX: 5 |> withY: 10
// => Point(x: 5, y: 10)
> p withX: 5; withY: 10
// => Point(x: 1, y: 10)        (fan-out: unchanged, and now warned — part 3)

Precedence and layout.

For Elixir and Gleam users. The |> spelling is chosen so BEAM developers recognise it on sight: the value on the left flows into the step on the right, read top to bottom. The one difference to learn is where the value lands. In Elixir and Gleam it becomes the first argument of a function; in Beamtalk it becomes the receiver of a message. Because a Smalltalk receiver sits where an Elixir first argument sits, the shapes line up one-for-one (each row is a separate stage, not one chain). The first row shows the one stylistic difference: idiomatic Beamtalk does not pipe the head, because orders select: … already sends to orders; Elixir needs orders |> Enum.filter(…) only because Enum.filter is a function, not a message to orders.

ElixirGleamBeamtalk
orders |> Enum.filter(&paid?/1)orders |> list.filter(is_paid)orders select: [:o | o isPaid]
|> Enum.map(& &1.amount)|> list.map(fn(o) { o.amount })|> collect: [:o | o amount]
|> Enum.sum()|> int.sum|> sum
|> Map.put(:a, 1)|> dict.insert("a", 1)|> at: #a put: 1

The function name (Enum.map) becomes a selector on the value (collect:); the module disappears because the value's class decides which method runs. There is no capture syntax (Elixir's &, Gleam's _) for putting the value anywhere but the receiver; when it must be an argument (Logger info: x), use then: (below), a temp local or the nested form. The language-features guide gets this table, and the parse error for a non-message stage (x |> 10) points at it.

Error examples.

p withX: 5 |> withY: 10; withZ: 3
// error: cannot mix cascade `;` and pipeline `|>` in one expression;
//        parenthesise the part you mean

p withX: 5 |>
// error: expected a message after `|>`

p withX: 5 |> 10
// error: expected a message after `|>` (found a literal) — `|>` sends a
//        message to the previous result; it does not apply a function

d at: #k |> + 1
// error: a pipeline stage cannot start with a binary message;
//        write `(d at: #k) + 1`

x |> keys sort
// fine: `(x keys) sort`; a stage is a whole message chain, not one message

then: for the value-as-argument case. Elixir's & and Gleam's _ can put the piped value anywhere; |> only makes it the receiver. For the other cases, Object gains one method, named after Elixir's Kernel.then/2:

/// Answer the result of evaluating aBlock with the receiver.
then: aBlock :: Block => aBlock value: self
average := orders collect: [:o | o amount]
  |> then: [:xs | xs sum / xs size]

It is an ordinary message, so it works without |> too (x then: [...]). Its declared signature follows Object >> ifNotNil: (notNilBlock :: Block => notNilBlock value: self), which leaves the block bare for the same reason (BT-2834). Pharo spells the same method in:; the Elixir name is chosen for this ADR's audience. Nothing in the stdlib, the runtime or a current ADR defines then: today. (ADR 0034's Future then: is superseded.) Forwarding proxies that rely on doesNotUnderstand: (TimeoutProxy, the TransparentProxy example) would answer then: themselves rather than forward it. BT-4515 either forwards it explicitly in those proxies or documents the behaviour. then: ships after |> (blocked by BT-4514): on its own, then: written after a keyword message merges into it (see Option E). It is deliberately not sealed, so a user class that already defines then:, such as a promise type, keeps compiling and overrides it.

Unlike ifNotNil:, then: is not inlined by the compiler. That has three consequences, which the docs state:

A stage the previous result does not understand raises does_not_understand exactly as the nested form would, and the type checker reports it at the stage's span (it sees an ordinary send).

AST representation (decided 2026-11-09): the parser desugars, and a side table restores the source as written. No Expression::Pipeline variant exists. The parser builds each pipeline directly as the left-nested MessageSends it means, and the tree is identical to the one the hand-nested form ((recv m1) m2) m3 produces.

Alongside the tree, the parser records which sends were written with |>: the span of each send whose message followed a |> token. The record is carried on the definition that owns the code (the MethodDefinition, and the Module for top-level and REPL expressions), not passed as a separate argument. So every unparse_method or unparse_module call sees it without a caller having to remember to pass it. Spans are unique (§ Spans), and normalisation and cloning keep them, so the record still matches after the operand-paren peel.

Consequences of this design:

  1. Analysis, codegen and most tooling see ordinary sends. This covers:

    • name resolution, type inference, the ADR 0131 recognisers, ThreadedIr and codegen;
    • the LSP's position features (definition, hover, signature help);
    • the senders, references, announce-sites and field-accesses queries;
    • @expect collection and the lints.

    None of them gains an arm, and none can silently skip a pipeline, because nothing exists to skip. This is what keeps |> free of state-threading risk: from the parser onward, a pipeline is the nested send the compiler already lowers. The normalisation pass, its has_parenthesised_operand gate and assert_operands_normalised are unchanged.

  2. Re-sugaring is the only new consumer work. It is needed in three places:

    • unparse, used by beamtalk fmt;
    • as_written_method_source (codegen generator/mod.rs);
    • the REPL ClassBuilder path.

    The last two rebuild a method's text from the normalised tree, then restore the parentheses recorded in PeeledParens. They must also print |> before each recorded send. Otherwise (MyClass >> #sel) source shows nested sends, and the workspace, which compares that text with the file on disk, reports the method as modified.

    • The cost of this design. A re-sugaring path that ignores the record prints the equivalent nested form instead of failing to compile.
    • Mitigation. The record lives on the definition, so the usual unparse entry points get it automatically. A round-trip corpus test (unparse/tests/canonical_source.rs) requires parse → fmt and parse → reflected source to reproduce every pipeline fixture byte for byte. The fixtures include comments between stages and pipelines in blocks, match: arms, string interpolation and collection literals.
  3. Token-level tooling. Two things work on tokens, not the AST:

    • Completion right after |>: the language service sees a PipeGt token before the cursor and completes against the type of the expression that ends there.
    • The editor grammars and the liveview highlighter: they lex |> as one token.

Comments between stages. A multi-line pipeline invites a trailing // … on a stage. Comments currently attach only at statement level, and the workspace compares reflected source with the file on disk. So fmt and the reflected-source restore must keep a comment between stages, or every method that has one is reported as modified. BT-4514 decided where such a comment attaches: to the record entry of the send whose |> follows it. An end-of-line comment after the previous stage is that entry's trailing comment, and comments on their own lines before the |> are its leading comments. A comment after the last stage stays the statement's own trailing comment. The round-trip corpus above covers it.

Rejected: an Expression::Pipeline variant desugared in normalisation. This was the original design. It gives the formatter the pipeline's structure directly, and the compiler forces every match site to decide what to do with a pipeline. Its costs:

All of that protects the few re-sugaring paths, which the round-trip test protects more cheaply. A defaulted SendForm marker field on MessageSend was rejected too, because it touches the ~480 MessageSend construction sites.

Spans (amended 2026-11-09). Each synthesised send gets the span the hand-nested form would give it: from the start of its receiver (the pipeline head) to the end of its message, receiver.span().merge(…) as in parse_keyword_message. It does not get just the stage as written. Span-keyed analysis facts depend on this: dispatch_kinds and state_effects (semantic_analysis/facts.rs) and the type map.

The wire check adds a test that every span in a desugared pipeline is unique and contains its receiver's span.

Diagnostics. A diagnostic on a pipeline stage is reported at that stage's message span. That is the message's own selector-and-arguments span inside the synthesised send, so withY: 10, not the whole chain. It points at the right place without special wording. A message that says "the receiver of this send" means the previous stage's value, and the span shows which one.

3. A cascade-drops-update warning for value cascades

A cascade gets a warning, at the dropped message, when all of:

warning[cascade-drops-update]: the result of `withX:` is discarded
  p withX: 5; withY: 10
    ^^^^^^^^^
  = note: `Point` is a value: `withX:` answers a new Point and leaves `p`
          unchanged, and a cascade sends `withY:` to `p`, not to that result
  = help: to send `withY:` to the result, use a pipeline:
          p withX: 5 |> withY: 10

Part 3 ships before part 2 and does not depend on it. Until |> exists, or if it is rejected, the help suggests the nested form ((p withX: 5) withY: 10) instead.

Two cases the rule above leaves open (added 2026-11-09):

REPL limitation. REPL bindings carry names, not types, so in the REPL p withX: 5; withY: 10 has a Dynamic target and does not warn. The REPL transcript in part 2 shows the result, not a diagnostic. A type-free trigger (two or more synthesised with*: selectors in one cascade) would cover that case. It is a possible follow-up.

It does not fire on Dynamic targets, actors, Object instances, non-final messages answering some other type (printString, size), or methods inherited from Object (yourself, show:). It is a warning with the usual @expect cascade_drops_update / [diagnostics] cascade-drops-update = "off" controls, not a guarantee — a dynamic receiver still fans out silently, as it always has. Known false positives: a value method declared -> Self that also has a side effect (logs, validates, sends to an actor) and is cascaded for that effect; @expect covers them.

The check needs inferred types, so it lives in the type checker beside infer_cascade (type_checker/inference/cascade.rs), which already resolves the cascade target's type and each message's dispatch — not in the AST-only validators of lint_validators.rs. It reads declared return types from the class hierarchy; no new selector table. The setUp lint fix below is syntactic and uses the existing with*: recogniser (crate::synthetic_selectors::with_star_selector).

The cascade_candidate lint (beamtalk-lint) suggests turning 3+ consecutive statements to one receiver into a cascade. Left alone, on a value receiver it would suggest exactly the cascade the new warning then flags. Those statements were already discarding each update, so the rewrite would preserve meaning but suggest a shape that is now warned. The lint therefore skips a run of sends that the new warning would flag. Such a run is itself a dropped-update bug (p withX: 5. alone discards its result). Catching discarded copies at statement level is a separate, broader lint and is out of scope here; it shipped as the discarded-update warning (BT-4522), which shares the cascade_drops_update predicate. The same change corrects check_testcase_setup_drops_field_assignments: a setUp ending in a self with*: cascade with more than one with*: message is no longer accepted as self-producing (it drops all but the last). cascade-drops-update already reports that shape at each dropped message, so the setUp lint adds no second warning of its own. It still warns when the type checker cannot prove every drop, for example when a dropped with*: is a hand-written method with no -> Self annotation (BT-4573). Until |> ships, its help suggests the nested form.

What stays valid regardless

Prior Art

LanguageSame-receiverChain-on-resultNotes
Smalltalk-80 / Pharo / Squeak;none (parens, temps); yourself idiom exists because ; is fan-out. Recurring pharo-dev threads (2010, 2014) asked for |> / "pipe operator"; answers pointed to library approaches (Vassili Bykov's asPipe proxy, a DNU-based chain in PharoFunctional) and nothing was merged.
Cuis Smalltalk;::Cuis added :: to its compiler so keyword messages chain like unary ones: #(1 2 3) raisedTo: 2 :: max: [:x | x] :: negated — each message goes to the previous result. The closest prior art to this ADR: a Smalltalk keeping ; and adding a separate chain token. We adopt the semantics, not the token (:: is Beamtalk's type-annotation operator, including x :: T := e in expression position).
Newspeak;noneKeeps Smalltalk cascades unchanged.
Dart.. (cascade).Cascade answers the receiver, not the last result; ordinary . chains. Two operators, two meanings.
Elixir—|>Pipes the previous value as the first argument of a function. Beamtalk's |> pipes it as the receiver of a message — the message-send analogue.
F# / OCaml—|>Same token, function application.
Gleam—|>Same token; BEAM peers will recognise it.
Kotlinapply/alsolet/runLibrary scope functions — the "do it with blocks" alternative (see Alternatives).
C# LINQ—.ADR 0042 noted LINQ as "pipeline cascade in expression context"; |> covers the same ground.

What we adopt: Cuis's split — ; for fan-out, a distinct token for chaining. What we adapt: the token, choosing |> because BEAM developers (Elixir, Gleam) already read it as "the thing on the left flows into the right". What we reject: changing ; itself (no surveyed language with a cascade redefines it by receiver type).

User Impact

Newcomer (Python/JS/Ruby). Method chaining (a.b().c()) is native to them; p withX: 5 withY: 10 failing (it is one withX:withY: message) and ; not chaining are both surprises. |> gives them the chain they expect, and the cascade-drops-update warning turns the silent ; mistake into a pointed message that names |>. They now have two operators to learn; the warning teaches the difference at the moment it matters.

Smalltalk developer. ; behaves exactly as in Pharo; yourself keeps its meaning. |> is a departure, but Cuis has shipped the same idea (as ::), and it removes a Smalltalk pain point that ADR 0042's immutable values make far more frequent than in an image of mutable objects.

Erlang/Elixir/Gleam developer. |> is the same token and the same top-to-bottom reading as in Elixir and Gleam — a design goal, not an accident — with one difference the docs state up front: the value flows into the receiver, not the first argument (see "For Elixir and Gleam users" above). Generated Core Erlang is identical to the nested form, so debugging and stack traces are unchanged.

Production operator. No runtime change: same BEAM code as hand-nested sends, no new dispatch, no hot-reload implications.

Tooling developer. The parser desugars |>, so every AST consumer sees an ordinary nested send. That includes type inference, lints, hover, definition, signature help, and the senders and references queries. Only the re-sugaring paths need new work: unparse/fmt, reflected method source and the REPL ClassBuilder path. They read the per-definition record of |> sends. Completion after |> is token-driven and offers the previous stage's selectors. Editor grammars lex |> as one token. The formatter needs one layout rule (one stage per line when broken). Re-sugaring is the bulk of the operator's tooling cost (§ AST representation).

Steelman Analysis

Option B — type-dependent cascade (ADR 0042's leading candidate)

Why it still loses: the mechanism is chosen from information the compiler does not reliably have (question 2). A Dynamic receiver needs a run-time kind test at every cascade, and Object instances and Erlang terms have no right answer at all (an Ets table must fan out; it is neither a Value nor an Actor). Adding a type annotation could silently flip a cascade's meaning. x foo; yourself becomes x foo on values. Existing fixtures such as 0 max: 1; max: n change results.

Option C — uniform pipeline ;

Why it loses: it breaks every actor/builder cascade whose messages answer something other than the receiver — ClassBuilder name: answers the Symbol, Transcript show: answers nil, Ets at:put: answers the value — so Object classBuilder name: #Foo; superclass: Object; register would send superclass: to #Foo. It discards the Smalltalk meaning ADR 0039 kept, and every existing cascade would need auditing.

Option A — status quo (fan-out; nesting and temps)

Why it is not enough on its own: the trap is silent. Part 3 (the warning) is the piece of this ADR closest to Option A and could be accepted alone; the |> operator is the part that removes the reason people reach for ;.

Option E — library-level chaining (then: blocks / asPipe proxy)

Why it loses as the primary answer: (st then: [:s | s withA: 1]) then: [:s | s withB: 2] is longer than the nesting it replaces and needs the parentheses, because without them it is one then:then: send. That same hazard means a then: written after a keyword message without |> (xs inject: 0 into: […] then: […]) is swallowed into inject:into:then:. With |> in front, the stage boundary prevents this, which is one more reason then: is adopted as a |> companion (§ Decision) rather than a substitute; a DNU-forwarding proxy (st asPipe withA: 1; withB: 2; value) is slow, hides the real receiver from the type checker and LSP, and relies on ; meaning something else on the proxy.

Tension points

Alternatives Considered

The motivating example under each candidate:

// A. Status quo — nested parentheses
self store: ((((st withWebsock: websock) withWebsockState: websock)
  withWebsocketOptions: opts) withRespState: #upgraded)

// A'. Status quo — temp locals
st1 := st withWebsock: websock
st2 := st1 withWebsockState: websock
st3 := st2 withWebsocketOptions: opts
self store: (st3 withRespState: #upgraded)

// B / C. Cascade-as-pipeline (`;` chains on a value)
self store: (st withWebsock: websock; withWebsockState: websock;
  withWebsocketOptions: opts; withRespState: #upgraded)

// D. Dedicated pipe operator (this ADR)
self store: (st withWebsock: websock
  |> withWebsockState: websock
  |> withWebsocketOptions: opts
  |> withRespState: #upgraded)

A. Status quo

Explicit nesting or temp locals. Correct and unambiguous, but the readable-looking ; form silently drops updates. Retained as always-valid spellings; not chosen as the whole answer because nothing flags the trap.

B. Type-dependent cascade (pipeline on values, fan-out on actors)

ADR 0042's leading candidate. Rejected: semantics depend on static type information that gradual typing does not guarantee; Dynamic receivers need a per-cascade run-time kind test (new runtime dispatch, slower, and invisible in the source); Object instances and Erlang terms have no correct classification; ; yourself loses its meaning on values; existing value cascades (0 max: 1; max: n) change results; and cascades on self in a value method would no longer match cascades on self in an actor method. Also forces a ThreadedIr decision for pipeline-on-self inside value-type methods (SelfVt threading) that the nested form never raises.

C. Uniform pipeline ;

Rejected: breaks Smalltalk parity (ADR 0039), every builder/actor cascade whose messages do not answer self (ClassBuilder, Transcript, Ets), and the yourself idiom.

D′. Other tokens for the pipeline operator

E. Library-level chaining

Object >> then: aBlock or a DNU-forwarding asPipe proxy. Rejected as the primary answer (see Steelman). then: is adopted as a complement to |> for the value-as-argument case (§ Decision); the proxy is not.

F. Multi-field functional update

A single message that sets several fields at once (e.g. a generated with: #{#websock => ws. #respState => #upgraded} or a keyword form withWebsock: … respState: …). It would serve the motivating example directly — arguably better than any chain, because it allocates one copy — but only for field updates of a single value; it does nothing for collection pipelines or non-with*: messages. Complementary and out of scope: it becomes a separate, low-priority issue (§ Resolved).

G. Warning plus multi-field update, no new operator

Accept part 3 and Alternative F, reject part 2. This fixes the trap and the motivating example with no new syntax; collection chains of unary messages already read left-to-right without parentheses. This is the strongest rival to the full proposal and the right answer if the in-repo frequency of deep keyword chains (see Context § Current state: low) is taken as representative. Not taken (§ Resolved): F does not cover keyword-heavy collection pipelines (select: → collect: → inject:into:), which is the case BT-506 was opened for, and the maintainer wants |> for Elixir and Gleam users.

H. Formatter-only: lay out nested chains one send per line

Teach beamtalk fmt to break a left-nested keyword chain into one send per line with aligned parentheses. Improves readability with no language change, but the reader still counts parentheses to find where each stage ends, and the ; trap is untouched. Compatible with any option; not a substitute for part 3.

I. Make the warning an error where it is certain

For a cascade whose non-final message is a compiler-synthesized with*: setter on a statically-known Value target, the dropped update is certain (the setter has no side effects), so the compiler could reject it outright. Not proposed: errors on well-formed Smalltalk are a bigger step than ADR 0039 allows without evidence the warning is ignored; the warning can be promoted later.

Consequences

Positive

Negative

Neutral

Implementation

Phases for /plan-adr; sizes are rough.

  1. Warning only (S/M) — cascade-drops-update in the type checker beside infer_cascade, using its resolved target type and the hierarchy's declared return types (defining class a value kind, type arguments ignored); its help suggests the nested form until |> ships; run it over stdlib and the test corpus, list the hits and add @expect where the fan-out is intended; fix check_testcase_setup_drops_field_assignments's multi-with*: cascade acceptance; make cascade_candidate skip runs the warning would flag. Independent of the operator; ships first.

  2. Wire check (S/M). This comes before the full parser work.

    • Lex |>.
    • Parse a pipeline at statement level directly into nested MessageSends, with hand-nested spans.
    • Record the |> sends on the owning MethodDefinition / Module.
    • Teach unparse and as_written_method_source to re-sugar.
    • Tests:
      • one end-to-end BUnit test on value, actor and Dynamic receivers;
      • just verify-threaded-ir;
      • a span-uniqueness test;
      • a check that (Cls >> #sel) source and fmt round-trip the |>.

    This proves the "no codegen change" assumption and the re-sugaring design before the rest lands.

  3. Lexer + parser (M) — TokenKind::PipeGt (adjacent |> only) in source_analysis/lexer.rs; |> stages at every parse_cascade site in parser/expressions.rs; the ;/|> mixing error; the "cast in expression" error for a pipeline ending in !; |> stages at the eight parse_keyword_message sites (string interpolation, match: arm bodies, collection literals), with ; keeping its arm-separator meaning in arms; the binary-stage error; line-continuation for a leading |>; PipeGt in is_input_complete's trailing-incomplete tokens. Parser tests for each, plus a tests/repl-protocol/cases/ case for multi-line REPL input. The stage parser is the keyword-expression parser with an implicit receiver (not parse_cascade_message), with tests that |> keys sort and |> foo at: 1 stay one stage and that a stage starting with BinarySelector/Arrow/GtGt is rejected. Object >> then: in stdlib/src/object.bt (not sealed), with BUnit tests on value, actor and class receivers, plus the type-checker rule that types a literal block's parameter as the receiver (next to infer_args_for_if_not_nil).

  4. Source fidelity (M).

    • beamtalk fmt layout: one stage per line when broken.
    • Re-sugaring on the REPL ClassBuilder path.
    • Comments between stages.
    • The full round-trip corpus in unparse/tests/canonical_source.rs: blocks, match: arms, string interpolation, collection literals and comments.
    • The editor grammars under editors/, including the liveview highlighter, which treats | as a binary character today.
  5. Language service (S) — completion after a PipeGt token against the type of the expression before it. Tests show that hover, definition and signature help on a stage already work, because they see the nested sends; no new arms are expected.

  6. Docs & tests (S) — docs/beamtalk-language-features.md (Cascades + new Pipelines section), docs/beamtalk-syntax-rationale.md (new departure row), BUnit tests in stdlib/test/ for values, actors and Dynamic receivers, parser tests for precedence, layout and errors. docs/development/surface-parity.md: no new operation, but two existing rows change. complete (shared by the REPL, MCP, LiveView and LSP) must offer the same candidates after |> on every surface. browse-method-source (LiveView) and the REPL's (Cls >> #sel) source must show |> as written.

No codegen, ThreadedIr, or runtime changes are expected. If the wire check (phase 2) needs one, the desugar-to-nested-sends design has failed and the ADR should be revisited before phases 3–6.

Migration Path

Nothing breaks: every existing program compiles and runs with the same meaning, and |> was not previously valid syntax. Object >> then: is not sealed, so a user class that already defines then: keeps its own method. Two changes do surface new diagnostics on code that compiles cleanly today, and each lands with the fix-up in the same PR:

Projects that build with --warnings-as-errors see both as failures until they fix or suppress the hits; a build without that flag lists every hit as a warning first.

Open Questions (for the maintainer)

None remain. The 2026-11-09 review reopened the AST design, and the maintainer settled it the same day (below). Every earlier question was settled on 2026-11-06.

Resolved (2026-11-09)

Resolved (2026-11-06)

Each of these was an open question in an earlier draft. Where the decision is the stricter choice, loosening it later is cheap; tightening it later would break code.

Implementation Tracking

Epic: BT-4511 Status: Done (epic closed 2026-11-10). Phase 1 shipped 2026-11-09 (BT-4512, jamesc/beamtalk#4920; BT-4513, jamesc/beamtalk#4919; follow-up BT-4573); Phases 2–4 shipped 2026-11-10. A later epic child, BT-4620 (warn on a then: block that doesn't take one parameter), landed 2026-11-11.

PhaseIssueSizeBlocked byStatus
1BT-4512: cascade-drops-update warningM—Done
1BT-4513: setUp lint rejects multi-with*: cascadesS—Done
2BT-4514: wire check (lex |>, parser desugar, re-sugaring record)M—Done
2BT-4515: Object >> then: and its typing ruleSBT-4514Done
3BT-4516: complete |> parsing and errors, REPL multi-lineMBT-4514Done
3BT-4517: source fidelity (unparse, fmt, reflected source, editors)MBT-4514Done
3BT-4518: completion after |>SBT-4514Done
4BT-4519: docs and end-to-end REPL-protocol caseSBT-4512, BT-4515, BT-4516, BT-4517, BT-4518Done

Follow-ups outside the epic (low priority, needs-spec):

References