Dynamic arrays allocation size

"Luís "Luís
Tue Mar 26 16:08:23 PDT 2013


BTW, in platforms (defined not just by the hardware, but the OS, 
etc) where at least one of the C types did not exactly match any 
of D's types then there would be an interesting problem. In 
core.stdc.config the C types are defined as aliases to D types, 
but if you had, say, a 256-bit long long then you'd be up for 
trouble :-). You couldn't do as is done currently with the 
aliases:

version( Windows )
{
     alias int   c_long;
     alias uint  c_ulong;
}
else
{
   static if( (void*).sizeof > int.sizeof )
   {
     alias long  c_long;
     alias ulong c_ulong;
   }
   else
   {
     alias int   c_long;
     alias uint  c_ulong;
   }
}

An interesting idea would be to have the standard types defined 
at the current sizes but allowing other sizes, other overflow / 
underflow behaviors (unspecified, exception, wrapping, 
saturation...), etc.

I don't expect that to happen, but just saying, it would be cool 
:-)


More information about the Digitalmars-d mailing list