On Fri, 09 Mar 2012 18:16:56 -0500, Brad Anderson <e...@gnuk.net> wrote:

On Fri, Mar 9, 2012 at 3:56 PM, Jonathan M Davis <jmdavisp...@gmx.com>wrote:

On Friday, March 09, 2012 17:41:01 Steven Schveighoffer wrote:
> I'll say I *don't* agree with the rejection of aliases on principle --
> aliases can be extremely useful/helpful, and they cost literally nothing
> (the "cognitive cost" on the docs is a BS argument IMO). I just don't
> agree with consuming so many common symbols for the sake of sugar.

aliases need to have a really good argument for existing. If UFCS is fully
implemented, then I think that there is _some_ argument for having stuff
like
hours and minutes, because then you can do stuff like 5.seconds() (though honestly, I really don't like the idea). The alias enables different usages
rather than simply being another name for the same thing.

Now, in this particular case, it's that much worse for exactly the reason
that
you're against it: it uses common names for free functions. It's not as
big a
problem as it would be in C or C++, but it's still a problem. There's also
some risk that it will break code.


Oh, and I'd just like to add some of my experience to this. These names are
used by Boost's datetime library and they've never been a problem for me
and at work we make extensive use of Boost datetime.  There is risk but I
think in this specific case they are fairly small (especially in D, over
C++).

I want to stress again the difference between C++'s namespaces, and D's module import mechanism. In C++, you *deliberately* pull a namespace into your scope (and usually only in the implementation file, which doesn't affect any other implementation files), whereas in D, a standard "import std.datetime" *automatically* pulls its namespace into your scope, and any public imports it has made.

I've used boost's datetime. I didn't really like the whole "different types for each unit" mechanism, but I used it with success, and was glad I didn't have to re-invent it :) But then again, I used it as the original date/time lib for my project.

-Steve

Reply via email to