Change representation of dynamic arrays?

Walter Bright newshound1 at digitalmars.com
Sat Oct 20 00:31:18 PDT 2007


Anders F Björklund wrote:
> Walter Bright wrote:
> 
>> What does this break?
>>
>> 1) Passing dynamic arrays to printf as in:
>>
>>     printf("my string is %*.s\n", str);
> 
> I think you meant to write printf("my string is %.*s\n", str);
> 
> Which is something of an argument against printf in itself :-)

Yes.

> 
>> which relied on the under-the-hood representation. This doesn't work 
>> on some architectures anyway, and is thoroughly obsolete. One could 
>> quickly fix such code by writing it as:
>>
>>     printf("my string is %*.s\n", str.length, str.ptr);
> 
> Yes, but that change had to be done sooner or later anyway...
> 
> Same as with the cast from char[] to ulong, dirty hacks both.
> 
>> So, what do you think?
> 
> Good riddance.

LOL!



More information about the Digitalmars-d mailing list