dstring - was Re: next version of DWT?

Marcin Kuszczak aarti at interia.pl
Mon May 14 13:01:46 PDT 2007

Chris Miller wrote:

> Well, I just wasn't sure. I'm still wondering what others think about this
> limitation. I wrote dstring mainly to see how it would go.
> A billion characters seems plenty to me; and this is just for 32-bit
> binaries. I could be wrong. I also figured those who need incredibly large
> strings will probably want to write special-purpose string handling code
> anyway, and it would seem odd that they would pass such large strings to
> functions that don't expect them to be so large (e.g. std.string.replace
> on a 1.5 gig string? yikes).

Hmmm... I have not clear feeling about that after your explanation...
Consider the fact that "mbox" e-mail storing files (having internally text
format) can quite easily reach 1 GB... Probably it is not so rare...
My "inbox" is about 180 Mb now, and in business environments there is much
more emails in inboxes...

> You don't need to check if it fits because it does that for you and throws
> an exception.

This is good :-)

> 8 bytes, nicely aligned struct, vs. 9 bytes? or maybe 12 bytes? It was
> designed to be easy to pass to functions and pack into other structures,
> like char[]. Adding to it will kill these benefits, especially the ability
> to return into registers.

4 bytes length + 4 bytes pointer? To say true I never use such low level
programming and never care about that... There should really other people
say something about this... What would be use case for such a feature? It
would help me to understand your motivation...

> Any dchar added to it doesn't do it; it will only if it can't fit into a
> single char or wchar. To get to dchar requires characters outside the BMP
> even, which can be quite rare.

Good to know...

> I believe Python is going to be using "dchar" for any Unicode strings
> beyond ASCII. I think dstring's way at least saves more than this.
>> 5. It's not standard (not included in Phobos nor in Tango)
> Agreed; I don't even use dstring at the moment.

Did you consider to post your implementation to Tango team? I think it would
be really valuable to have it in Tango. I would say it should be on basic
level (object.di ?). At least you could get feedback: why it doesn't fit in
Tango. (I would be interested to know it also.)

With possible future additions of opImplicitCast to D dstring could work
nicely with all kinds of char arrays in both ways, so that you could send
string to function which was written for char[] and have implicitly
converted string to char[]. The same should happen in opposite way
(char[] -> string). This way dstring could nicely integrate with types
already available in D. I really don't feel much need for other solutions
which doesn't help with hiding complexity of different character arrays...

Marcin Kuszczak (Aarti_pl)
Ask me why I believe in Jesus - http://zapytaj.dlajezusa.pl (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/

More information about the Digitalmars-d-dwt mailing list