digitalmars.D.announce - New string implementation: dstring 1.0
- Chris Miller (5/5) Oct 11 2006 Check out the FAQ at http://www.dprogramming.com/dstring.php and give it...
- Chad J (17/23) Oct 11 2006 Looks cool!
- Chris Miller (10/32) Oct 12 2006 Yes, they are the same; they both state returning UTF-8 so I didn't thin...
- Kristian (15/20) Oct 13 2006 Good work indeed. Now slicing can be done... Thanks. :)
- Fredrik Olsson (9/15) Oct 24 2006 I love it! This is very much needed and should go into Phobos yesterday!
- Aarti_pl (13/33) Oct 24 2006 I didn't write it before when DString was introduced, but I got also
- Chris Miller (3/29) Oct 24 2006 But then it won't be ultra fast at finding dchar codepoints.
- Fredrik Olsson (7/13) Oct 24 2006 A little thought. Two bits are now used to represent the internal
- Chris Miller (4/15) Oct 24 2006 Neat idea. Currently it uses that 4th state to represent an uninitialize...
- Olli Aalto (17/23) Oct 24 2006 Hi!
-
Chris Miller
(20/41)
Oct 24 2006
On Tue, 24 Oct 2006 06:30:48 -0400, Olli Aalto
... - Olli Aalto (7/52) Oct 24 2006 Yes, and it's what makes the usefulness of the module pretty limited.
Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!
Oct 11 2006
Chris Miller wrote:Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!Looks cool! I'm to strapped on time to try it out right now, but I will when I get the chance. I do have a couple questions and a comment based on the documentation: - Is toString() the same as toUTF8()? If so, I'd like to see something in the documentation to say they are the same. - Are there plans to extend this to act as a string manipulating library as well as a string type, adding stuff from phobos like toUpper(), toLower(), capitalize(), split(), etc? That would be cool. - Seems like it would be handy to have functions for converting to C style null terminated strings. Something like char* toUTF8C() and wchar* toUTF16C(). This looks like a very useful string type. I just hope that if people like it, it becomes part of the standard library or some such so that newbs aren't caught by indexing/slicing in the current string-as-array approach. Anyhow, thanks for doing that.
Oct 11 2006
On Wed, 11 Oct 2006 17:27:52 -0400, Chad J spamIsBad gmail.com"> <"<""gamerChad" "> wrote:Chris Miller wrote:Yes, they are the same; they both state returning UTF-8 so I didn't think it was necessary. It mainly only has toString for consistency with other D types and so it will work directly with writef.Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!Looks cool! I'm to strapped on time to try it out right now, but I will when I get the chance. I do have a couple questions and a comment based on the documentation: - Is toString() the same as toUTF8()? If so, I'd like to see something in the documentation to say they are the same.- Are there plans to extend this to act as a string manipulating library as well as a string type, adding stuff from phobos like toUpper(), toLower(), capitalize(), split(), etc? That would be cool.If there is enough interest, yes.- Seems like it would be handy to have functions for converting to C style null terminated strings. Something like char* toUTF8C() and wchar* toUTF16C().I wasn't sure about this because it's not guaranteed that C uses Unicode; but I guess toUTF8z(), toUTF16z() and toUTF32z() would be fine, which only mean zero-terminated, not necessarily compatible with C.This looks like a very useful string type. I just hope that if people like it, it becomes part of the standard library or some such so that newbs aren't caught by indexing/slicing in the current string-as-array approach. Anyhow, thanks for doing that.Thanks
Oct 12 2006
On Wed, 11 Oct 2006 20:40:18 +0300, Chris Miller <chris dprogramming.com> wrote:Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!Good work indeed. Now slicing can be done... Thanks. :) I am wondering if D itself should support something like this. Well, even if 'char[]' will be aliased to 'string', it would make code clearer for everybody (IMHO). It would tell that this is a string, not an array of characters. (It alone would make the aliasing meaningful, not to mention that you cannot slice char[] safely.) I think one should be aware of dstring's worst case memory consumption. For example, a huge file is read to a dstring. There is only one character that would make the whole string to use dchars instead of char. The string would then take four times more space than char[] would. Of course, if one would use char[], he/she couldn't slice it (in O(1) time). :) (And it would be probably necessary to write special routines for special cases anyway.)
Oct 13 2006
Chris Miller skrev:Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!I love it! This is very much needed and should go into Phobos yesterday! Solves the problem of: char[] foo = "hög"; assert(foo.length == 3); // Sorry UTF-8, this is == 4 assert(foo[1] == 'ö'); // Not a chance! You implementation of string could be a perfect wrapper that makes the fact that UTF-8 is of variable char size, invisible to the programmer. // Fredrik Olsson
Oct 24 2006
Fredrik Olsson napisał(a):Chris Miller skrev:I didn't write it before when DString was introduced, but I got also very positive feelings about it. As a programmer in common cases I should not be bothered about implementation details of string. It should not matter if I work with char[], wchar[] or dchar[]. I agree that it should be putted in Phobos immediately! (Maybe just some optimalizations with string size could be added, so adding one dchar to char[] string will not cause conversion from char[] to dchar[], but rather dchar to char). Regards Marcin Kuszczak Aarti_plCheck out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!I love it! This is very much needed and should go into Phobos yesterday! Solves the problem of: char[] foo = "hög"; assert(foo.length == 3); // Sorry UTF-8, this is == 4 assert(foo[1] == 'ö'); // Not a chance! You implementation of string could be a perfect wrapper that makes the fact that UTF-8 is of variable char size, invisible to the programmer. // Fredrik Olsson
Oct 24 2006
On Tue, 24 Oct 2006 05:12:21 -0400, Aarti_pl <aarti interia.pl> wrote:Fredrik Olsson napisał(a):Thanks guys.Chris Miller skrev:I didn't write it before when DString was introduced, but I got also very positive feelings about it. As a programmer in common cases I should not be bothered about implementation details of string. It should not matter if I work with char[], wchar[] or dchar[].Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!I love it! This is very much needed and should go into Phobos yesterday! Solves the problem of: char[] foo = "hög"; assert(foo.length == 3); // Sorry UTF-8, this is == 4 assert(foo[1] == 'ö'); // Not a chance! You implementation of string could be a perfect wrapper that makes the fact that UTF-8 is of variable char size, invisible to the programmer. // Fredrik OlssonI agree that it should be putted in Phobos immediately! (Maybe just some optimalizations with string size could be added, so adding one dchar to char[] string will not cause conversion from char[] to dchar[], but rather dchar to char).But then it won't be ultra fast at finding dchar codepoints.
Oct 24 2006
Chris Miller skrev: <snip>A little thought. Two bits are now used to represent the internal format, but there are only three formats available. Maybe the fourth format code could be "size optimal, but slightly slower"? I mean, just what else should quad 2ghz machines do? :) // Fredrik OlssonI agree that it should be putted in Phobos immediately! (Maybe just some optimalizations with string size could be added, so adding one dchar to char[] string will not cause conversion from char[] to dchar[], but rather dchar to char).But then it won't be ultra fast at finding dchar codepoints.
Oct 24 2006
On Tue, 24 Oct 2006 06:20:44 -0400, Fredrik Olsson <peylow gmail.com> wrote:Chris Miller skrev: <snip>Neat idea. Currently it uses that 4th state to represent an uninitialized string, but that's not so important. I'll think about this.A little thought. Two bits are now used to represent the internal format, but there are only three formats available. Maybe the fourth format code could be "size optimal, but slightly slower"? I mean, just what else should quad 2ghz machines do? :)I agree that it should be putted in Phobos immediately! (Maybe just some optimalizations with string size could be added, so adding one dchar to char[] string will not cause conversion from char[] to dchar[], but rather dchar to char).But then it won't be ultra fast at finding dchar codepoints.
Oct 24 2006
Chris Miller wrote:Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!Hi! The dstring module is very nice, but it's lacking one thing that I, at least personally, am gotten used to. It's that you cannot assign a null to it. string str = null; or string getAStringWhichMightBeNull() { return null; } It's not a big thing but makes using the string a bit clumsy. One another thing. Not necessarily dstring's fault, but I tried compiling it with C::B in release mode. I had set every compiler option available for the release build and when I compiled I started getting errors about functions not returning any values. They were functions which had switches, which default cases had return statements. I don't know which flag causes this behavior, but a debug build works just fine. O.
Oct 24 2006
On Tue, 24 Oct 2006 06:30:48 -0400, Olli Aalto <olli.aalto cardinal.fi> = = wrote:Chris Miller wrote:=Check out the FAQ at http://www.dprogramming.com/dstring.php and give=it a spin. Documentation is online at ==http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!Hi! The dstring module is very nice, but it's lacking one thing that I, at=least personally, am gotten used to. It's that you cannot assign a nul=l =to it. string str =3D null;I don't think this is possible. The string is also automatically initialized to an empty/null string.or string getAStringWhichMightBeNull() { return null; }There is string(), such as: string mystring =3D string(); or: myfunction(string());It's not a big thing but makes using the string a bit clumsy. One another thing. Not necessarily dstring's fault, but I tried =compiling it with C::B in release mode. I had set every compiler optio=n =available for the release build and when I compiled I started getting ==errors about functions not returning any values. They were functions =which had switches, which default cases had return statements. I don't know which flag causes this behavior, but a debug build works ==just fine.I'm only getting this when using -w to get DMD to output warnings. I thi= nk = DMD's warnings are terrible and I never use or consider them. Please don= 't = use this switch.
Oct 24 2006
Chris Miller wrote:On Tue, 24 Oct 2006 06:30:48 -0400, Olli Aalto <olli.aalto cardinal.fi> wrote:Yes, and it's what makes the usefulness of the module pretty limited. Empty string is not the same as a null string. Maybe this is just my Java background.Chris Miller wrote:I don't think this is possible. The string is also automatically initialized to an empty/null string.Check out the FAQ at http://www.dprogramming.com/dstring.php and give it a spin. Documentation is online at http://www.dprogramming.com/docs/dstring/dstring.html Let me know what you think!Hi! The dstring module is very nice, but it's lacking one thing that I, at least personally, am gotten used to. It's that you cannot assign a null to it. string str = null;I didn't get this part.or string getAStringWhichMightBeNull() { return null; }There is string(), such as: string mystring = string(); or: myfunction(string());I didn't have the -w switch on. I used -inline -O -release switches. O.It's not a big thing but makes using the string a bit clumsy. One another thing. Not necessarily dstring's fault, but I tried compiling it with C::B in release mode. I had set every compiler option available for the release build and when I compiled I started getting errors about functions not returning any values. They were functions which had switches, which default cases had return statements. I don't know which flag causes this behavior, but a debug build works just fine.I'm only getting this when using -w to get DMD to output warnings. I think DMD's warnings are terrible and I never use or consider them. Please don't use this switch.
Oct 24 2006