Hacker News new | ask | show | jobs
by WalterBright 1663 days ago
Wow, and someone else just yesterday was giving D credit for not thrusting everything into the global name space like C does!

Yes, two different D modules can declare the same name as public, and they will not conflict with each other.

1 comments

Apologies if I misworded what it's doing.

It wasn't about name clashing, but readability. It's not clear at first glance what functions belong to which imports.

As an example: https://tour.dlang.org/

Three imports and what appear to be four unqualified functions from them.

I'm sorry you don't like it, but that's a feature! But if there are identical names from two different imports, the compiler will demand that you qualify them.

Or just use static import.

With all respect for all the work you've done in C++ and D but imo that is a mistake. This is one of the reasons I have a distaste for languages like C# and Ruby and prefer languages like Python and Rust. I've had a hard time following what is happening in other people's Ruby code because of this behavior. Whether items are imported from a module should be left up to the developer and not done on their behalf.
> Whether items are imported from a module should be left up to the developer and not done on their behalf.

Well, the developer wrote `import thing;` instead of either `static import thing;` or `import thing : specific, list;` so it was their decision.

What language are you used to that doesn't do this? I think I would go nuts if I had to always use the fully qualified name for all symbols.