Skip to content

proposal: Move attempt and Exit to Std.Exit - #489

Draft
Allianaab2m wants to merge 3 commits into
mainfrom
refactor/std-exit
Draft

Allianaab2m wants to merge 3 commits into
mainfrom
refactor/std-exit

Conversation

@Allianaab2m

Copy link
Copy Markdown
Member

attempt と Exit(Success,Failure)を Std.Fiber から新しい Std.Exit に移す.Fiber.attempt(f) は Exit.attempt(f) になる.Cause は Std.Cause のまま.

Proposal: proposals/std-exit.md(status: draft).実装と spec の変更も同じ PR に入れてある.

理由

  • attempt はファイバーを作らず,その場で f を走らせて Fail と Die を値にするだけで,並行と関係ない
  • Std.Fiber を import しているリポジトリ外のコードは,どれも attempt しか使っていない
  • 依存が Std.Fiber → Std.Exit → Std.Cause の一方向になる.Fiber.await は Std.Exit の Exit を返す

変更

  • crates/emela-core/lib/std/exit.emel を足し,Exit と attempt(@intrinsic)を移した.fiber.emel は Std.Exit.{Exit} を import する
  • intrinsic の表(sources.rs)と lowering の対応(lower/fiber.rs)を ("Std.Exit", "attempt") にした.Exit の enum は intrinsic の戻り値の型から引くので,IR と JS・C・WASM のコード生成はモジュール名に依存していない.emb の "Std.Fiber.Exit" だけ名前で比べていたので "Std.Exit.Exit" にした
  • C runtime の descriptor 名とコメントを Exit.attempt にした
  • spec: [fiber],[fiber.cause],[error.defect],[lib.layers],[api.std.fiber],[api.std.exit](新設),[api.std.cause],[target.c.unsupported]
  • Std.Http の launch,テストのプログラム,Rust テストの中の Emela ソース,README,snapshot を書き換えた
  • CHANGELOG の Unreleased に Breaking として書いた
  • 移行期間は置かない(match の postfix 化と同じ方針).enum は再 export できないので,Fiber.attempt を残しても Success と Failure の import は壊れる

spec/history.md は /accept の bot が書くので触っていない.過去の history の項目と採択済みの proposal は記録なので書き換えていない.

追従が要るリポジトリ外のコード

  • x/sql:トランザクション
  • deploy/control/src/sqlite.emel
  • brix(src/pbt/property.emel):import Std.Fiber.{Success, Failure} と Fiber.attempt.tests/laws が brix v0.3.0 に依存しているので,CI の laws はこの PR では落ちる. brix を直してリリースし,tests/laws/Pome.lock を上げるまで merge できない

確認したこと

  • cargo nextest run --workspace:1613 passed(wasmtime 50 を PATH に入れて WASM の parity も実行)
  • cargo fmt --check,cargo clippy -D warnings,scripts/spec.py check
  • examples/* の emela check・test・fmt --check
  • tests/laws:brix の 15 errors で落ちる(上記)

Fiber.attempt(f) は Exit.attempt(f) に,Exit,Success,Failure の import は
Std.Exit からにする.古い名前は残さない(proposals/std-exit.md).
@Allianaab2m Allianaab2m added the proposal A proposal to change the specification (proposals/) label Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

proposal A proposal to change the specification (proposals/)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant