Coder Social home page Coder Social logo

Comments (4)

billcxx avatar billcxx commented on July 19, 2024 1

Thanks for the explanation. I'm just thinking what I may need for the future, so I don't have an actual use case yet. I will create issue/PR for documentation if I meet and solve problems dealing with absent data in my program.

from toml-f.

awvwgk avatar awvwgk commented on July 19, 2024

The (optional) fourth argument in the getter interface for tables is the default value.

Usually you do not need to explicitly check for presence. The has_key type bound procedure can be used, but I recommend the error handling recipe instead on ways to check directly using the getter interface.

from toml-f.

billcxx avatar billcxx commented on July 19, 2024

Thanks for the quick explanation. Sorry for my ignorance, but one more question, is the "error handling recipe" you mentioned referring to the stat optional argument in the get_value interface?

I see snippets like this in the How-Tos/Reporting errors

    call get_value(table, "timestep", config%timestep, 0.5, stat=stat, origin=origin)
    if (stat /= 0) then
      print '(a)', context%report("Cannot read timestep", &
        & origin, "expected real value")
      stop 1
    end if

from toml-f.

awvwgk avatar awvwgk commented on July 19, 2024

I don't think there is an explicit recipe yet targeting this topic. The error reporting recipe does this touch a bit, also there are some mentions in the table handling recipe section.

If you have a specific use case it might be useful to add it to the recipes and describe how absent data is dealt with. However, the general design strategy of TOML Fortran's getter interface should allow to minimize the need to worry about the existence of keys or entries.

from toml-f.

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.