size_t + ptrdiff_t

Artur Skawina art.08.09 at gmail.com
Sun Feb 19 15:47:34 PST 2012


On 02/20/12 00:17, Manu wrote:
> On 20 February 2012 01:10, kennytm <kennytm at gmail.com <mailto:kennytm at gmail.com>> wrote:
> 
>     Manu <turkeyman at gmail.com <mailto:turkeyman at gmail.com>> wrote:
>     > I propose size_t + ssize_t should both exist, and represent the native
>     > integer size.
> 
>     sizediff_t (currently just aliased to ptrdiff_t but the link could be
>     broken).
> 
>     > Also something like ptr_t, and ptrdiff_t should also exist,
>     > and represent the size of the pointer.
>     >
> 
>     core.stdc.stdint.uintptr_t
> 
> 
> O_o .. how is this different to size_t now? Why the redundant alias?

C compatibility?
It is redundant in D, at least  until it supports non-flat address spaces. :^)

uintptr_t can hold a pointer, size_t only the size of something. These
days there's usually not much difference, but take eg x86_16 segments - 
you can have several 'views' into memory, that allow for <= size_t-sized
objects, but a full 'address' of such an object won't fit into a size_t.

artur


More information about the Digitalmars-d mailing list