ReviewOS

home-lang/home

Switch arm syntax — `=>` (match-style) vs `case`/`default` (C-style)

#20
Closed glennmichael123 opened this 24 days ago · 0 comments
24 days ago

Context

10 home-os kernel modules use `switch` statements with match-style `=>` arrows:

```home switch (event) { BRCMF_E_LINK => { handle_link() } BRCMF_E_DISCONNECT => { handle_disconnect() } } ```

The parser expects `case`/`default` keywords inside `switch` and rejects `=>` arrows. Meanwhile, `match` already uses `=>` arrows — so the kernel writers (reasonably) reached for the same form in `switch`.

Affected files

`kernel/src/drivers/wifi/broadcom.home`, `kernel/src/drivers/wifi/iwlwifi.home`, `kernel/src/i18n/bidi.home`, plus 7 more (full list in `~/Desktop/home-os-kernel-audit-2026-05-04-pm.tsv`, filter `first_error` = `Expected 'case' or 'default' in switch statement`).

Question for the language design

Two options:

  1. Unify `switch` and `match` — accept `=>` arms in `switch` too. They become syntactic siblings; `match` is the more general form (with destructuring, guards, etc.) and `switch` is the simple-equality flavor. Or even drop `switch` as a keyword in favor of just `match` everywhere.
  2. Keep them distinct — `switch` requires `case Pattern: ...` C-style, `match` keeps `=>` arrows. Mass-migrate the home-os kernel to `case`/`default` style.

Option 1 is simpler for users and matches what the kernel code already assumes. Option 2 is more conventional (Zig has `switch` with `=>`; Rust has `match` with `=>`; C/Go/JS have `switch` with `case`).

Recommended: Option 1, with `switch` accepting `=>` arms. Aligns with what kernel writers naturally wrote and removes a syntactic gotcha. `match` and `switch` differ in features (destructuring, exhaustiveness checking) but share arm syntax.

Why this matters

10 modules unblocked once decided. #2 of 5 ranked follow-ups in the 2026-05-04-pm audit. Listed as `question` label until the design call is made.

Reference

  • Audit: `~/Desktop/home-os-kernel-audit-2026-05-04-pm.tsv`

Sign in to comment on this issue.