Giter Club home page Giter Club logo

Comments (8)

jeff-cohere avatar jeff-cohere commented on August 12, 2024 1

Okay, that's a fair point. I don't particularly sympathize with anyone who gets all sorts of errors when they use using namespace std, but we probably don't want to contribute any more to the confusion.

from ekat.

bartgol avatar bartgol commented on August 12, 2024

If you issue, say, using std::min in your app code, then I believe that min(a,b) should work, no?

from ekat.

bartgol avatar bartgol commented on August 12, 2024

Actually, we are already providing min/max in ekat_math_utils.hpp. Does your code compile if you include that header? I guess we could add a similar one for abs in that file...

from ekat.

jeff-cohere avatar jeff-cohere commented on August 12, 2024

The ones in ekat_math_utils.hpp seem to be under the ekat::impl namespace, which suggests "no touchy!". But yeah, we could just use these. Is there any reason to stash them in the impl namespace?

from ekat.

bartgol avatar bartgol commented on August 12, 2024

Ah, yeah, you're right. I guess we put them there to not explicitly pollute ekat's namespace, in case the user does using namespace ekat, but doesn't want these overloads.

from ekat.

jeff-cohere avatar jeff-cohere commented on August 12, 2024

It seems like a user who includes that header might not mind having those functions available in the ekat namespace. Otherwise they get only theis_invalid and transpose functions.

from ekat.

bartgol avatar bartgol commented on August 12, 2024

I think that names like max or min are so common that it would be somewhat dangerous to inject them into ekat's namespace. I can see apps doing using namespace ekat, but if they also are doing (ugh) using namespace std (or any other library namespace that declares max/min), then there might be compile/link errors (or worse, runtime ones).

I'm ok moving unambiguous names outside of the impl namespace, but max/min (and even isfinite) are shared with the std lib, which imho is too dangerous to do it by default. If someone is interested in getting those functions, they can do using namespace ekat::impl. It's a one line price to pay, but it gives more security long term.

from ekat.

bartgol avatar bartgol commented on August 12, 2024

I agree, using the std namespace is not a great practice. But on the other hand, there are likely other libs that may overload such common name functions...

from ekat.

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.