Against deprecating aliases

Jonathan M Davis jmdavisProg at gmx.com
Wed Sep 28 23:36:57 PDT 2011


On Thursday, September 29, 2011 08:22:41 Jacob Carlborg wrote:
> On 2011-09-28 21:56, Jonathan M Davis wrote:
> > Having toUTF and toUTFz is a marked improvement in many cases -
> > especially for generic code. They're being added regardless of what the
> > deal with toUTF16z is.
> > 
> > The reason that toUTF16z is being removed is essentially because Andrei
> > is very much opposed to having functions with specific types in their
> > names and thinks that they should all be generic. Personally, I'm not
> > opposed to keeping toUTF16z as an alias or wrapper to toUTFz. It's
> > Andrei that seems to feel stongly about it. So, if enough people really
> > want to keep toUTF16z, then I think that that can happen.
> 
> Seems a bit arbitrary what gets deprecated with the old API left in
> place and what gets deprecated with the old API removed.

I'm not sure that I understand. Very little gets deprecated with the old API 
immediately removed, and _everything_ which gets deprecated will be eventually 
removed (or it wouldn't be deprecated). What are you thinking about in 
particular?

Do you mean that if we decide to leave toUTF16z but not other things, it's a 
bit arbitrary? Well, if that's what you mean, for one, not much is being left. 
In general, it's replaced, and the old function is deprecated and eventually 
removed. And two, if toUTF16z were to stay, it would be because calling toUTFz 
is much uglier. To do what you do with toUTF16z with toUTFz, you end up doing 
toUTFz!(const(wchar*))(str) instead of to toUTF16z(str).

So, toUTFz works much better for generic code, it cuts down on code 
duplication in some cases, and it's more flexible, but it's uglier to call, so 
if you have to call it all over the place it's annoying. So, if a bunch of 
people complained, we might keep toUTF16z because of that, since it caters to 
a common use case. But as it stands, it's going to be removed, and very little 
in Phobos which has had a new function come along to replace it and yet still 
stuck around in the long term. toStringz is the only thing that I can think of 
off the top of my head that's done that, and that's primarily because it's been 
around for so long and is so heavily used (and also in part due to the fact 
that it's just cleaner to use it for the common case).

- Jonathan M Davis


More information about the Digitalmars-d mailing list