Jump to page: 1 24  
Page
Thread overview
Rename std.string.toStringz?
Jun 16, 2011
Jonathan M Davis
Jun 16, 2011
Peter Alexander
Jun 16, 2011
Daniel Gibson
Jun 16, 2011
Timon Gehr
Jun 16, 2011
Jesse Phillips
Jun 16, 2011
Regan Heath
Jun 16, 2011
KennyTM~
Jun 16, 2011
Dmitry Olshansky
Jun 16, 2011
Dejan Lekic
Jun 16, 2011
Mafi
Jun 16, 2011
Jonathan M Davis
Jun 16, 2011
Adam D. Ruppe
Jun 16, 2011
Jonathan M Davis
Jun 16, 2011
Adam D. Ruppe
Jun 16, 2011
Jonathan M Davis
Jun 17, 2011
Alix Pexton
Jun 17, 2011
Timon Gehr
Jun 16, 2011
Alix Pexton
Jun 16, 2011
Kagamin
Jun 16, 2011
Daniel Gibson
Jun 16, 2011
Mike Parker
Jun 16, 2011
Daniel Gibson
Jun 16, 2011
Kagamin
Jun 16, 2011
Kagamin
Jun 16, 2011
Daniel Gibson
Jun 17, 2011
Kagamin
Jun 17, 2011
Daniel Gibson
Jun 17, 2011
Dmitry Olshansky
Jun 17, 2011
Kagamin
Jun 17, 2011
Kagamin
Jun 17, 2011
Daniel Gibson
Jun 17, 2011
Kagamin
Jun 17, 2011
Daniel Gibson
Jun 17, 2011
Jonathan M Davis
Jun 16, 2011
Mike Parker
Jun 16, 2011
KennyTM~
June 16, 2011
Okay. I have an open pull request whose main goal is to rename various string and character functions so that they're properly camelcased (as has been discussed previous in this group): https://github.com/D-Programming- Language/phobos/pull/101

All in all, I think that the renaming in there is fairly obvious and non- controversial. However, we have the problem of std.string.toStringz. toStringz isn't properly camelcased (at least, _I_ would definitely argue that it isn't). Currently (in that pull request), I have it renamed to toStringZ (with the old version still around and scheduled to be deprecated, so no code would break immediately if it were merged in). But some have said that they consider toStringz to be properly camelcased (apparently they view stringz as a special word indicating a zero-terminated string). Another suggestion was to rename it to toCString (which is arguably much more obvious for newbies). In addition to that, we have std.utf.toUTF16z, which matches the naming scheme that toStringz has, so if we rename toStringz, we should probably rename toUTF16z as well (to toWCString?). Certainly, there's no consensus on what to do with the name of toStringz.

Now, toStringz is probably one of the most heavily used string functions in Phobos. If we rename it, a _lot_ of code is going to have to be changed. So, if we rename it, we need to give it a name which most people would consider better than toStringz and worth the consistency that we gain with regards to the naming of functions in Phobos. So, the question is, should we

1. Keep toStringz as it is (as well as toUTF16z) and either consider stringz to be some sort of word unique to the D community or just admit that we're not going to camelcase it because it would break too much code to do so.

2. Just camelcase it properly and rename it to toStringZ (and probably rename toUTF16z to toUTF16Z). Code will have to be changed, but the function is still immediately recognizable to long time D programmers.

3. Rename it to toCString (probably renaming toUTF16z to something like toWCString), so it's then more recognizable to newbies, but it'll take some getting used to for everyone else (and of course require lots of code to be changed).

4. Rename toStringz to something else which is properly camelcased.

I don't like leaving toStringz as it is because of its casing, but I also don't want to cause code breakage without general agreement on the replacement name. It's just too important of a function to change the name of willy-nilly. So, I'm looking to see what everyone else thinks.

Thoughts? Opinions?

- Jonathan M Davis
June 16, 2011
On 16/06/11 7:30 AM, Jonathan M Davis wrote:
> Thoughts? Opinions?
>
> - Jonathan M Davis

My preference is on a change to toCString. I've never liked toStringz, and it seems that a common question among newbies is "how do I pass this string to C libraries?". I think changing it to toCString will make it more obvious.
June 16, 2011
Am 16.06.2011 08:30, schrieb Jonathan M Davis:

> 
> 3. Rename it to toCString (probably renaming toUTF16z to something like toWCString), so it's then more recognizable to newbies

This + keep around aliases for the old names until D3.

Cheers,
- Daniel
June 16, 2011
I am against the change for ... social reasons.

Simply put, the D community is used to toStringz . I might be wrong, but I think we are all familiar with this function and use it on a daily basis. :)

However, if you really, really want to stick to the coding convention, and decide to rename it anyway, I would go for toCString ...

Kind regards

Dejan Lekic
June 16, 2011
On 16/06/2011 07:30, Jonathan M Davis wrote:

> 1. Keep toStringz as it is (as well as toUTF16z) and either consider stringz
> to be some sort of word unique to the D community or just admit that we're not
> going to camelcase it because it would break too much code to do so.

I vote for no change, I like stringz as it is ^^

A...
June 16, 2011
c_str
c_wstr

similarly to c_long
June 16, 2011
Am 16.06.2011 13:01, schrieb Kagamin:
> c_str
> c_wstr
> 
> similarly to c_long

So c_long converts a long to a c-long?
(Is this a D function/type? I couldn't find it on the homepage)
June 16, 2011
Daniel Gibson wrote:
> Am 16.06.2011 08:30, schrieb Jonathan M Davis:
>
>>
>> 3. Rename it to toCString (probably renaming toUTF16z to something like toWCString), so it's then more recognizable to newbies
>
> This + keep around aliases for the old names until D3.
>
> Cheers,
> - Daniel

+1. But make it 'toCWString'. :o)

Timon
June 16, 2011
On 6/16/2011 3:30 PM, Jonathan M Davis wrote:

>
> 1. Keep toStringz as it is (as well as toUTF16z) and either consider stringz
> to be some sort of word unique to the D community or just admit that we're not
> going to camelcase it because it would break too much code to do so.
>

My vote goes for this one.
June 16, 2011
On 6/16/2011 7:59 PM, Daniel Gibson wrote:
> Am 16.06.2011 13:01, schrieb Kagamin:
>> c_str
>> c_wstr
>>
>> similarly to c_long
>
> So c_long converts a long to a c-long?
> (Is this a D function/type? I couldn't find it on the homepage)

It's not a conversion function, but an alias. It's declared, along with c_ulong, in core.stdc.config.
« First   ‹ Prev
1 2 3 4