Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 10, 2011 [phobos] sizediff_t | ||||
---|---|---|---|---|
| ||||
One question - we don't have a type for the difference of two size_t objects. That would be int on m32 and long on m64. C has historically used ptrdiff_t for that, but not all size differences are pointer differences, so gnu has acknowledged that by defining ssize_t ("signed size_t" I suppose). While being in a crunch making some 64-bit changes I defined the type sizediff_t. I wonder if that's okay as a permanent solution. Andrei |
January 10, 2011 [phobos] sizediff_t | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Yes we do, ptrdiff_t, defined in object.
Andrei Alexandrescu wrote:
> One question - we don't have a type for the difference of two size_t objects. That would be int on m32 and long on m64. C has historically used ptrdiff_t for that, but not all size differences are pointer differences, so gnu has acknowledged that by defining ssize_t ("signed size_t" I suppose).
>
> While being in a crunch making some 64-bit changes I defined the type sizediff_t. I wonder if that's okay as a permanent solution.
>
|
January 10, 2011 [phobos] sizediff_t | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | I was aware of the presence of ptrdiff_t in druntime. Part of my point is that the name is sometimes a misnomer in C (which led to the definition of ssize_t) and even more so in D, where entire programs can be written without ever using the notion of "pointer".
So my question boils down, I think, to: do we go with "ssize_t" or "sizediff_t"?
Andrei
On 1/10/11 10:27 PM, Walter Bright wrote:
> Yes we do, ptrdiff_t, defined in object.
>
> Andrei Alexandrescu wrote:
>> One question - we don't have a type for the difference of two size_t objects. That would be int on m32 and long on m64. C has historically used ptrdiff_t for that, but not all size differences are pointer differences, so gnu has acknowledged that by defining ssize_t ("signed size_t" I suppose).
>>
>> While being in a crunch making some 64-bit changes I defined the type sizediff_t. I wonder if that's okay as a permanent solution.
>>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
January 11, 2011 [phobos] sizediff_t | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Why is it a misnomer? When, in C, would you use ssize_t rather than ptrdiff_t? Are they ever a different type?
(If you're going to do it, it should be ssize_t.)
Andrei Alexandrescu wrote:
> I was aware of the presence of ptrdiff_t in druntime. Part of my point is that the name is sometimes a misnomer in C (which led to the definition of ssize_t) and even more so in D, where entire programs can be written without ever using the notion of "pointer".
>
> So my question boils down, I think, to: do we go with "ssize_t" or "sizediff_t"?
>
>
> Andrei
>
> On 1/10/11 10:27 PM, Walter Bright wrote:
>> Yes we do, ptrdiff_t, defined in object.
>>
>> Andrei Alexandrescu wrote:
>>> One question - we don't have a type for the difference of two size_t objects. That would be int on m32 and long on m64. C has historically used ptrdiff_t for that, but not all size differences are pointer differences, so gnu has acknowledged that by defining ssize_t ("signed size_t" I suppose).
>>>
>>> While being in a crunch making some 64-bit changes I defined the type sizediff_t. I wonder if that's okay as a permanent solution.
>>>
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
|
January 11, 2011 [phobos] sizediff_t | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 1/11/11 1:21 AM, Walter Bright wrote: > Why is it a misnomer? When, in C, would you use ssize_t rather than ptrdiff_t? Are they ever a different type? I don't think they're a different type. One place I've seen that use is in file I/O. > (If you're going to do it, it should be ssize_t.) Okay. Andrei |
January 11, 2011 [phobos] sizediff_t | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 01/11/2011 06:46 AM, Andrei Alexandrescu wrote: > One question - we don't have a type for the difference of two size_t objects. That would be int on m32 and long on m64. C has historically used ptrdiff_t for that, but not all size differences are pointer differences, so gnu has acknowledged that by defining ssize_t ("signed size_t" I suppose). > > While being in a crunch making some 64-bit changes I defined the type sizediff_t. I wonder if that's okay as a permanent solution. Isn't sizediff_t already defined somewhere? I have the following at start of each source file: // standard type aliases alias sizediff_t Ordinal; // index in sequence/range/whatever alias size_t Cardinal; // element count of a collection By the way, wouldn't it be time for D builtin names to conform to its own style guide (as published online)? Denis -- _________________ vita es estrany spir.wikidot.com |
Copyright © 1999-2021 by the D Language Foundation