Interesting Memory Optimization
Don Clugston
dac at nospam.com
Fri Mar 16 23:55:46 PDT 2012
On 16/03/12 13:24, Kevin Cox wrote:
>
> On Mar 16, 2012 7:45 AM, "Alex Rønne Petersen" <xtzgzorex at gmail.com
> <mailto:xtzgzorex at gmail.com>> wrote
> >
> > I don't see any reason why c couldn't point to element number 3 of b,
> and have its length set to 3...
> >
> > --
> > - Alex
>
> And the previous examples were language agnostic. In D and other
> languages where the length of a string is stored we can nest strings
> anywhere inside other strings.
>
> const char[] a = "foofoo";
> const char[] b = "oof";
>
> Those can't be nested in null terminated strings, bit they can where
> strings have an explicit length.
>
Unfortunately string literals in D have an implicit \0 added beyond the
end, so we don't have much more freedom than C.
More information about the Digitalmars-d
mailing list