Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AST mapping treats record labels as patterns; should they have type ident instead? #4263

Closed
vicuna opened this issue Apr 17, 2007 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Apr 17, 2007

Original bug ID: 4263
Reporter: nogin
Assigned to: ertai
Status: closed (set by @xavierleroy on 2010-04-29T12:18:05Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.10+dev
Fixed in version: 3.10+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Monitored by: nogin

Bug description

Currently Camlp4 AST defines the record patterns as

PaRec of loc and list (patt * patt)

and record expressions as

ExRec of Loc.t and binding and expr

where the binding can bind arbitrary patterns to expressions. This was not a big issue prior to 3.10, but now that 3.10 provides very powerful mapping and folding features, this seems a bit problematic. Namely, if I define a Camlp4 filter or an AST mapping function that affects patterns, the array labels will get affected as well, often in an undesired way.

Would it be better to have
PaRec of loc and list (ident * patt)
and
ExRec of loc and list (ident * expr) and expr
instead?

If so, it would seem that now is the time to make the change, as 3.10 is about to make major backwards-incompatible camlp4 changes anyway.

@vicuna
Copy link
Author

vicuna commented Apr 20, 2007

Comment author: ertai

That's now done in the CVS for patterns.

So << p1 = p2 >> becomes << i = p >>

@vicuna
Copy link
Author

vicuna commented Apr 27, 2007

Comment author: ertai

That's now done for expressions too.

I've introduced (as suggested) the rec_binding type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant