Giter Club home page Giter Club logo

Comments (5)

tomas-abrahamsson avatar tomas-abrahamsson commented on July 19, 2024

Sure, that could be a good thing, I'd be happy to provide any assistance needed

I initially thought using Erlang maps for map<_,_> type fields was tied to using maps instead of records for messages -- that's why it is currently connected to that -- but I think I can see the use case for maps type fields as maps even though messages are records.

I've kept unit tests that use Erlang maps in gpb_compile_maps_tests.erl so far. gpb still works fine even with pre-17 Erlangs, for records, of course (but it can actually generate code that use maps on such systems). The data-driven encoder/decoder in gpb is strictly records, no maps, no options, so no need to concern about that. In gpb_compile.erl, I believe the best way to go would be to add some function, for instance get_format_for_map_type_fields(Opts) -> tuple_list | map, and change some relevant calls currently to the get_records_or_maps_by_opts/1 into this new get_format_for_map_type_fields/1.

Things to think of, that are easily forgotten:

  • corresponding code for nifs
  • generation of type spec strings
  • The doc in the README.md
  • Doc in the gpb_compile:file/2
  • Any corresponding command option for this(?) (doc in 2 places -- unfortunately -- handling only in one place though)

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 19, 2024

Hi, I don't know if you have already done any work here yet or not? If not, I have a proposal for you on the branch mapfields-as-maps

from gpb.

tsloughter avatar tsloughter commented on July 19, 2024

Cool, I haven't done any work on it yet. Turned out I likely don't need it at work because of the clients having to stay on 2.x features. But am still interested in getting this in to gpb.

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 19, 2024

Ok. I think I'll first rework the current maps option, so that it expands to msgs_as_maps, mapfields_as_maps and defs_as_maps, in the light of the earlier issue. This should be fully backwards compatible, yet still offer the desired functionality.

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 19, 2024

The option expanding is now in the just-pushed 3.25.2, so you can specify just mapfields_as_maps to get what you're interested in. (closing)

from gpb.

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.