Code Monkey home page Code Monkey logo

Comments (3)

pitag-ha avatar pitag-ha commented on August 24, 2024

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.

zepalmer avatar zepalmer commented on August 24, 2024

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.

pitag-ha avatar pitag-ha commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.