Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 1
    Your question is unclear. Do you only want to spare the imports/includes, or any kind of dependency definition / library referencing? Commented Jan 14 at 15:25
  • 2
    It's easy enough with something obvious like cout, I'm not as sure that it's easy when you consider the entire family of things that may be pulled in by a simple-looking #include <iostream>, especially considering that (currently) the include is purely textual and performed by the pre-processor (so the existence of it is gone by the time the compiler takes a crack at it). Commented Jan 14 at 15:36
  • 2
    "While C++ can't necessarily guarantee that there isn't a competing std::cout out there, a language designed with this in mind could potentially (hypothesis)." How do you prevent two independent developers (or teams) from creating the same names? I don't see a way for a programming language (alone) to prevent that. Commented Jan 14 at 16:36
  • 2
    This question is similar to: Why don't languages auto import everything?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Jan 14 at 20:34
  • 2
    Even in your own example, you assert that the inference logic isn't ironclad, there is a 1% edge case. Time and time again, programming teaching you that logic requires you to be pedantically unambiguous about everything you mention, specifically because the logic/compiler refuses to make educated guesses. Your question is just another example of the same thing. Commented Jan 21 at 5:32