Rename std.string.toStringz?

Jonathan M Davis jmdavisProg at gmx.com
Sat Jun 25 17:31:06 PDT 2011


On 2011-06-25 15:28, Walter Bright wrote:
> On 6/18/2011 2:59 AM, Jonathan M Davis wrote:
> > Okay, clearly we're not going to reach any kind of consensus on this. We
> > seem to be pretty thoroughly split between those who want to keep it as
> > toStringz and those who want to rename it to toCString. Interestingly
> > enough, _no one_ seems to want to go with just camelcasing it to
> > toStringZ. But regardless, without anything close to a consensus on
> > this, it wouldn't make any sense to change the function's name and break
> > all of the code that doing that would break. So, it's going to stay
> > toStringz.
> 
> All these renames make me uncomfortable:
> 
> 1. They break existing code. Nobody likes recompiling an older piece of
> code and have it gratuitously break here, there, and everywhere.
> 
> 2. There is no such thing as a perfect name; bikeshed wars demonstrate
> this.
> 
> There ought to be a fairly high bar to renaming existing functions, not
> just a debatable and marginal improvement.

Which was why I was asking. Previous discussions in this group have made it 
clear that the majority want Phobos' functions to be consistently camelcased. 
toStringz arguably isn't but it's a bit of an oddball (some people have argued 
that it _is_ properly camelcased), and it's a heavily used function, so 
breaking code to rename it (for camelcasing or any other reason) has to be 
worth the gain. So, I started this thread to determine whether it was worth 
the gain, and the discussion has made it clear that many think that it isn't, 
so toStringz is sticking around. It looks like we're going to create a toUTFz 
which is more flexible (takes any string type and returns whatever character 
pointer type you template it on), but even then, toStringz will probably stick 
around (though it'll probably end up either calling toUTFz or being an alias 
to it - depending on whether it can be aliased; templated stuff often doesn't 
alias very well in my experience).

So, while the majority have indicated in the past renaming functions in Phobos 
to be properly camelcased is worth breaking code in the general case, there is 
no such consensus in this particular case, so toStringz is sticking around.

- Jonathan M Davis


More information about the Digitalmars-d mailing list