Comments (3)
Hello @zepalmer, thanks for the issue! You're right: Ast_builder
/Ast_pattern
should provide a way to construct/descruct nodes with attributes. The current workflow to build nodes with attributes is: Whenever metaquot
can't be used, we build the node without the attributes and then functionally update that node to add the attribute(s). I.e. we do exactly what you've described in your second approach mentioned above, but with custom pexp_with_attributes
-like functions. Given that it's extremely unlikely that the <node_name>_attributes
-field of a node will be renamed, that isn't a huge problem wrt stability, but it's true that we should provide an official way.
I also agree with your judgement for both your mentioned approaches: Adding an optional attrs
argument to the builder functions would be the ideal solution, but it would be more work to implement that. Adding a pexp_with_attributes
for all nodes allowing attributes that functionally updates the node to add attributes would be a worse but a reasonable lower-hanging alternative.
We currently have very little time for ppxlib
. Do you happen to want to work on this? I'd be happy to give some pointers. Both Ast_builder
and Ast_pattern
are generated modules, so the implementation of this needs to handle the generation logic.
from ppxlib.
I'm quite interested in making these adjustments contingent upon the timeline you have in mind. May I presume that there is no huge rush?
Given the opportunity, I think I'd like to implement both of the approaches described above. The functional update is useful in cases where we want to extend or filter attributes, for instance, which would otherwise require destructing and reconstructing the node. The work I've been doing, on the other hand, has been synthesizing some data structures to which I've wanted to add deriving annotations. So I see a use case for both approaches, but I'd obviously want the blessing of the project maintainers before I added anything. :)
from ppxlib.
I'm sorry, I've totally missed your answer.
I'm quite interested in making these adjustments contingent
That's great news, thank you!
May I presume that there is no huge rush?
Indeed, there's no rush. You can make your own timeline (and I'll try not to miss your messages anymore and answer questions with less delay).
I think I'd like to implement both of the approaches described above.
Sure, that sounds good. I'd appreciate a lot if you could then make the difference clear in the documentation, i.e. the API documentation and/or the manual, ideally both.
Do let me know if you have questions to get started!
from ppxlib.
Related Issues (20)
- Performance analysis
- Server mode
- Reduce the number of AST traversals
- Reserving an attribute namespace with a dot has unexpected semantics
- Ppxlib’s behaviour in case of raised exception. HOT 2
- trunk-support does't build with ocaml-trunk HOT 11
- Fixpoint and monadic combinators for `Ast_pattern` HOT 1
- The tests fail when using OCaml 5.1.1 HOT 7
- Add a driver mode with no output if there is no rewriting to do HOT 4
- Binary mode when writing to stdout on Windows HOT 7
- Unused-type declaration warning and bisect_ppx coverage points HOT 22
- ocaml.ppx.context's local_path format changes in OCaml 5.2 HOT 1
- Compiler error with OCaml 5.2.0 and an identity ppx HOT 3
- Remove Ppxlib's label exposed HOT 1
- Allow generation of type definitions using expression nodes HOT 2
- BUG: generating invalid ocaml syntax. HOT 2
- Generating recursive definitions with metaquot HOT 2
- Exp.fun_ appears to be unbound using ocaml 5.2 and ppxlib 0.32.1 HOT 5
- ppxlib and ocamlfind: looks like code_path is broken ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ppxlib.