Skip to content

Rename {P,T}exp_{struct_item => letitem}#14171

Closed
nojb wants to merge 1 commit intoocaml:trunkfrom
nojb:letitem
Closed

Rename {P,T}exp_{struct_item => letitem}#14171
nojb wants to merge 1 commit intoocaml:trunkfrom
nojb:letitem

Conversation

@nojb
Copy link
Copy Markdown
Contributor

@nojb nojb commented Jul 28, 2025

Following discussion over at #14040 this PR proposes to rename the Pexp_struct_item (and its typed tree avatar) to Pexp_letitem. The main rationale is that having let in the constructor name better reflects what the AST node is about. Pexp_let_struct_item could be an alternative, but it is a bit of a mouthful.

For discussion.

(NB: this constructor has not yet been released to the world, so renaming is still OK.)

@v-gb
Copy link
Copy Markdown
Contributor

v-gb commented Jul 28, 2025

(NB: this constructor has not yet been released to the world, so renaming is still OK.)

Renaming is fine regardless, it causes a bit of churn, but I don't think it's worse than, say, adding locations to the ast, which happens regularly.

@gasche
Copy link
Copy Markdown
Member

gasche commented Jul 28, 2025

I'm not fond of Texp_letitem. For example this name is easily confused with Texp_let: imagine a new code reader that hasn't looked the documentation yet, what would they guess about the difference between Texp_let, Texp_letop and Texp_letitem? (Personally my guess would be that let x1 = e1 and x2 = e2 in body has two "let items", x1 = e1 and x2 = e2).

Texp_struct_item is fairly unambiguous because there are few things that structure items can do in an expression. But if you would like to emphasize the concrete syntax, I think that Texp_let_struct_item and Texp_let_stritem would both be better than Texp_letitem.

@v-gb
Copy link
Copy Markdown
Contributor

v-gb commented Aug 16, 2025

I expect that the name would be understandable just fine in context. But I guess Pexp_letsomething is still better than the current name (ideally, using the most common shorthand for structure item, because it's annoying when each api randomly chooses between str vs stri vs struct_item vs structure_item, or pattern vs pat, or expression vs expr vs exp or typ vs ty etc).

But IMO, it would just be simpler to fold Pexp_let into Pexp_letitem anyway. Less invariants, more similarly between similar constructs this way.

@nojb
Copy link
Copy Markdown
Contributor Author

nojb commented Sep 3, 2025

Discussed further in today's triage meeting. All in all, there was no consensus in favour of this renaming, and some developers were in favour of the current name. Closing then due to lack of agreement.

@nojb nojb closed this Sep 3, 2025
@nojb nojb deleted the letitem branch September 3, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants