Giter Site home page Giter Site logo

Comments (5)

nncarlson avatar nncarlson commented on June 23, 2024 1

I'm intrigued by your serialization use case. If you can, and when you feel ready, I'd like to hear more about it.

from petaca.

nncarlson avatar nncarlson commented on June 23, 2024

Hello Thierry, Can you explain in more detail what you would like to be able to do. It's not quite clear to me.

from petaca.

trmwzm avatar trmwzm commented on June 23, 2024

Hello Neal. If I have 2 parameter_list(s), let's say read from JSONs, I am looking to add a type bound procedure to be able to do:

type(parameter_list) :: p, p1, p2

call parameter_list_from_json_stream(json_1_unit, p1)
call parameter_list_from_json_stream(json_2_unit, p2)

call p%set ('json 1', p1)
call p%set ('json 2', p2)

Should be relatively easy using recursion and the iterators already in library (?) I will try to give it a go.

from petaca.

nncarlson avatar nncarlson commented on June 23, 2024

I think you should be able to do something like that already:

type(parameter_list) :: p
type(parameter_list), pointer :: p1, p2

p1 => p%sublist('json 1')
p2 => p%sublist('json 2')

call parameters_from_json_stream(json1_unit, p1)
call parameters_from_json_stream(json2_unit, p2)

Note the use of parameters_from_json_stream instead of parameter_list_from_json_stream. The latter takes a pointer as an argument which it allocates and fills internally. The former takes a preexisting parameter list and adds to it.

That said, if one had an existing parameter list pointer p1, it would be very useful to be able to make it a new sublist of a parameter list p. So something like this:

call parameter_list_from_json_stream(json1_unit, p1)
...
call p%set_sublist('json 1', p1)

I've wanted this myself on several occasions. It's not always convenient or possible to create the empty sublist first and then fill it. Is this what you are looking for? This would be very easy to add.

from petaca.

trmwzm avatar trmwzm commented on June 23, 2024

Yes, creating a sublist and subsequently filling it would be a workaround. The use case I was thinking of is a hierarchy of list which mirrors that of class composition. A class would have a constructor using a plist as a unique argument, and a "to_plist()" serialization. I can easily modify "to_plist" to take a pre-allocated plist as additional argument. Thank you very much!

from petaca.

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.