Review: std.uuid

Jonathan M Davis jmdavisProg at gmx.com
Thu Jun 14 00:49:59 PDT 2012


On Thursday, June 14, 2012 09:41:53 Jacob Carlborg wrote:
> On 2012-06-14 08:57, Dmitry Olshansky wrote:
> > It feels this way because by default we import all symbols. The good
> > thing is that you don't care for conflicts as long as you don't touch
> > the conflicting name.
> 
> That's a good thing.

It is and it isn't. It makes it much easier to end up with conflicts. It would 
be less of a problem if not all symbols were imported by default. We _do_ have 
some great tools for dealing with conflicts, but the fact that everything gets 
imported by default when you import a module means that it's very easy to 
create conflicts, and when that's coupled with the fact that D is very quick to 
declare ambiguities and conflicts with overload sets and whatnot rather than 
trying to determine which one you really meant (like C++ would) makes it that 
much worse. There are definite pros to the situation (e.g. being so picky with 
overload sets makes it much harder to call the wrong function without knowing 
it), but there's no question that conflicts happen quite easily. It's not as 
big a deal with introducing a new module, since the programmer will deal with 
it when they import it for the first time, but it tends to break code when 
adding new stuff to old modules.

So, in general, if we can pick good names which don't conflict, we're better 
off. But if the best names are ones that are used in other modules, then that's 
what we'll end up going with. It has to be judged on a case-by-case basis.

> > One day we'd just have to use static import more often.
> 
> Or aliases, or renamed imports.

aliases are useless for dealing with conflicts as long as private aliases 
aren't hidden. At present, I'd argue that private aliases are bad practice 
unless you alias things to very esoteric names which aren't likely to conflict. 
It would really be nice to have that fixed though.

- Jonathan M Davis


More information about the Digitalmars-d mailing list