String convention

Niklas Ulvinge Niklas_member at pathlink.com
Sat Jul 1 13:07:30 PDT 2006


I could't find any info about it so I'm asking here...

I just looked at D and it sounds rather interesting.

Now to my Q:
Strings in D starts with some data that is defining the length of the string.
Why did they decide to use this aproach?
What is this 'data' at the beginning of the string?

This has a limitation, strings can't be longer than 'data' allows.
Is there a way around this?


An idea, I got when I wrote a dynamic array (in C), was to use s[-1] as the size
for array s (and s[-2] for capacity, but that isn't necesary here...).

Couldn't this be used with strings?
Then this would work:
string s = "IDK\0";
printf("%s",s);

Niklas Ulvinge
aka IDK wishes
everyone happy
programming!!!



More information about the Digitalmars-d mailing list