Giter Club home page Giter Club logo

Comments (12)

joedevivo avatar joedevivo commented on July 22, 2024

@Licenser could you include the real-world example you ran in to?

from cuttlefish.

Licenser avatar Licenser commented on July 22, 2024
  • The mDNS library I use auto detects the NIC to use unless a IP to use is specified in the app.config.
  • The main app will use either a autodetected or a specified IP/Port combination.

In the schema I tried to assing the mdns ip based on weather the ip/port is set, this needed a translation, which should not set anything in the app.config when ip/port is not set.

from cuttlefish.

joedevivo avatar joedevivo commented on July 22, 2024

@Licenser Would having the translation return 'undefined' when the IP/Port combination solve the problem?

from cuttlefish.

Licenser avatar Licenser commented on July 22, 2024

Yap, it would turn into {ok, undefined} with the get_env which is different form undefined aside of adding a third fork in the code path it'd break the claim that we can use get_env the same way as before ;)

from cuttlefish.

joedevivo avatar joedevivo commented on July 22, 2024

@Licenser what if you used get_env/3 instead of get_env/2?

from cuttlefish.

Licenser avatar Licenser commented on July 22, 2024

Not available in erlang R15 :(, that said in R16 I could put in the code to default to {ok, undefined} but that still would be kind of a horrible hackish solution.

from cuttlefish.

joedevivo avatar joedevivo commented on July 22, 2024

So it's no longer 'undefined' it's "defined as undefined"

from cuttlefish.

Licenser avatar Licenser commented on July 22, 2024

yea but get_env treats those two situations differently:

  • if it is undefined get_env(something) returns undefined
  • if it is defined as undefined then get_env(something) returns {ok, undefined}

from cuttlefish.

joedevivo avatar joedevivo commented on July 22, 2024

I'll take this scenario under advisement, but for now, your best bet is to add the third clause for reading this value:

{ok, undefined} -> blah;
undefined -> blah;
{ok, Value} -> blah

from cuttlefish.

Licenser avatar Licenser commented on July 22, 2024

To add to this I just thought of another issue, if someone were to use get_env/3 the default would not be picked when the value is set to undefined instead of not being defined at all breaking that behavior and being quite counter intuitive.

from cuttlefish.

joedevivo avatar joedevivo commented on July 22, 2024

get_env/3 has it's own issues, use at your own risk ;)

from cuttlefish.

seancribbs avatar seancribbs commented on July 22, 2024

@Licenser We now have an API function cuttlefish:unset() which can be used to skip emitting a value to the generated configuration. Closing this issue.

from cuttlefish.

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.