Skip to content

atdml: Add support for <ocaml field_prefix> + no prefix on function labels#455

Merged
mjambon merged 4 commits intomasterfrom
martin/field_prefix
Mar 11, 2026
Merged

atdml: Add support for <ocaml field_prefix> + no prefix on function labels#455
mjambon merged 4 commits intomasterfrom
martin/field_prefix

Conversation

@mjambon
Copy link
Collaborator

@mjambon mjambon commented Mar 11, 2026

Closes #433

PR checklist

  • New code has tests to catch future regressions
  • Documentation is up-to-date
  • CHANGES.md is up-to-date

mjambon and others added 3 commits March 10, 2026 20:40
Prefixes are applied to generated OCaml record field names but not to
labeled arguments in create_ functions, matching the task description
from issue #433 (last comment).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…check

Introduce make_prefixed_trs which builds two separate name translators:
- label_tr: keyword-checks the raw field name (no prefix) for labeled args
- pftr: concatenates the prefix with the raw name *then* keyword-checks,
  so "mod"^"ule" = "module" (keyword) → "module_", while the label is "ule";
  and "mod"^"if" = "modif" (not a keyword) → "modif", while the label is "if_".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test 'type t = { ule: int; if: int; if_: int } <ocaml field_prefix="mod">'.
Shows that "if_" (ATD) gets label ~if__ because ~if_ was already claimed
by the rename of the keyword field "if".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename all make_ → create_ (make_foo → create_foo, val make → val create)
- Add "Primitive type aliases" subsection: documents private type in .mli,
  create_* constructor, :> coercion, zero runtime overhead
- Extend "Reserved name handling" to mention record fields and variants
- Add "Field field_prefix" entry under Section ocaml: documents the
  annotation, the unprefixed-label / prefixed-field split, and the
  keyword-escaping semantics with the mod+ule/mod+if worked example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mjambon mjambon merged commit 25c9033 into master Mar 11, 2026
0 of 3 checks passed
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.

Make atdgen -v produce constructors whose label do not contain "field_prefix"

1 participant