On Wed, Nov 18, 2009 at 07:12:24AM +0100, J?rgen Hestermann wrote: > > And I think shortstring should generally be discouraged. The standard is > > always "255 is enough", but sooner or later somebody hits it: > > That's like saying that short integer types like byte or word should be > discouraged and only Int64 should be used.
Well, can be speed penalties on byte and word indeed. > Shortstrings are just a completely different string type than ansistrings. That's correct. > Therefore it is dangerous to use the generic string type because in > general a programer needs to know how the strings are stored, otherwise > significant bugs are likely. That goes for both shortstring and ansistring. > With Shortsstrings you don't have to think > about reference counters and other traps that can be cause hard to find > errors (i.e. when using ansistrings within a highly nested data > structure). No problem what so ever. ansistrings are safe unless you much in the internals on purpose. > Just think of a array of strings. If shortsstrings are used, all data is > in one block of memory (and on average 75% too large) > You can move it around and make copies of it. But > with ansistring this is not so easy. You only have an array of pointers. Assign them all of them, is a lot faster, since copy-on-write. Seriously, there are basket cases where shortstrings are useful. But that was not what this is about. In the general case, you should avoid them. -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus