Integer conversions too pedantic in 64-bit

Daniel Gibson metalcaedes at gmail.com
Wed Feb 16 10:32:09 PST 2011


Am 16.02.2011 19:20, schrieb Jonathan M Davis:
> On Wednesday, February 16, 2011 06:51:21 gölgeliyele wrote:
>> On 2/16/11 9:45 AM, Steven Schveighoffer wrote:
>>> I'm done with this thread...
>>>
>>> -Steve
>>
>> Ok, I don't want to drag on. But there is a reason why we have a style.
>> size_t is against the D style and obviously does not match. I use size_t
>> as much as Walter does in my day job, and I even like it. It just does
>> not fit into D's type names. That is all.
> 
> If we were much earlier in the D development process, then perhaps it would make 
> some sense to change the name. But as it is, it's going to break a lot of code 
> for a simple name change. Lots of C, C++, and D programmers are fine with size_t. 
> I see no reason to break a ton of code just because a few people complain about 
> a name on the mailing list.
> 
> Not to mention, size_t isn't exactly normal anyway. Virtually every type in D 
> has a fixed size, but size_t is different. It's an alias whose size varies 
> depending on the architecture you're compiling on. As such, perhaps that fact 
> that it doesn't follow the normal naming scheme is a _good_ thing.
> 
> I tend to agree with Steve on this. This is core language stuff that's been the 
> way that it is since the beginning. Changing it is just going to break code and 
> cause even more headaches for porting code from C or C++ to D. This definitely 
> comes across as bikeshedding. If we were way earlier in the development process 
> of D, then I think that there would be a much better argument. But at this 
> point, the language spec is supposed to be essentially stable. And just because 
> the name doesn't quite fit in with the others is _not_ a good enough reason to go 
> and change the language spec.
> 
> - Jonathan M Davis

Well IMHO it would be feasible to add another alias (keeping size_t), update
phobos to use the new alias and to recommend to use the new alias instead of size_t.
Or, even better, add a new *type* that behaves like size_t but prevents
non-portable use without explicit casting, use it throughout phobos and keep
size_t for compatibility reasons (and for interfacing with C).

But I really don't care much.. size_t is okay for me the way it is.
The best argument I've heard so far was from Michel Fortin, that having a more
D-ish name may encourage the use of size_t instead of uint - but hopefully
people will be more portability-aware once 64bit DMD is out anyway.

IMHO it's definitely too late (for D2) to add a better type that is signed etc,
like Don proposed. Also I'm not sure how well that would work when interfacing
with C.

It may make sense for the compiler to handle unsigned/signed comparisons and
operations more strictly or more securely (=> implicit casting to the next
bigger unsigned type before comparing or stuff like that), though.

Cheers,
- Daniel


More information about the Digitalmars-d mailing list