Elektrine lite

← Feed

@zwarich@hachyderm.io

Post #1490236

2026-04-15 22:16 UTC

One of the most pressing naming discussions of our time: when you have a sum type `Token`, `Expr`, etc. and then a wrapper containing it + some common info (like trivia for `Token`, a source span for other nodes) what do you call the two? I used to always default to `Expr` and `ExprData`, but rustc generally defaults to `ExprKind` and `Expr`, despite `ExprKind` containing lots of data beyond just the plain `enum` that it represents: https://doc.rust-lang.org/beta/nightly-rustc/rustc_ast/ast/enum.ExprKind.html Obviously, the best solution is to allow variants to have common fields, but is there a good naming scheme that works in the absence of this?

Replies (1)

  • @thalia@discuss.systems 2026-04-16 00:28

    @zwarich And the longer name is the one that's repeated in all `match` patterns! I don't like the `ExprKind` convention. In a current project, I even have a Kind enum (bare enum for coarse types) that's contained in a Kind enum (expression variant enum).

    Open ##1629767