Re: Fixing std.string

2010-08-24 Thread Michael Rynn
On Fri, 20 Aug 2010 02:22:56 +, dsimcha wrote: As I mentioned buried deep in another thread, std.string is in serious need of fixing, for two reasons: 1. Most of it doesn't work with UTF-16/UTF-32 strings. 2. Much of it requires the input to be immutable even when there's no good

Re: Fixing std.string

2010-08-24 Thread Jonathan M Davis
On Monday 23 August 2010 23:16:25 Michael Rynn wrote: The problems are combinatorial, because of encoding schemes. I imagine that when someone wants a function that is missing from std.string, they might write one, and might even add to it. A lot of functions in Phobos are templated on string

Re: Fixing std.string

2010-08-24 Thread Norbert Nemec
On 20/08/10 03:22, dsimcha wrote: 3. Is there any good reason to avoid just templating everything to work with all 9 string types (mutable/const/immutable char/wchar/dchar[]) or whatever subset is reasonable for the given function? Wouldn't it be sufficient to take const as input? IIRC, both

Re: Fixing std.string

2010-08-24 Thread Simen kjaeraas
Norbert Nemec norb...@nemec-online.de wrote: On 20/08/10 03:22, dsimcha wrote: 3. Is there any good reason to avoid just templating everything to work with all 9 string types (mutable/const/immutable char/wchar/dchar[]) or whatever subset is reasonable for the given function? Wouldn't

Re: Fixing std.string

2010-08-20 Thread Russel Winder
On Fri, 2010-08-20 at 02:22 +, dsimcha wrote: [ . . . ] 1. How did it get to be this way? Why did it seem like a good idea at the time to only support UTF-8 and only immutable strings? But isn't the thinking these days that immutable strings are a good thing? Immutability is generally a

Re: Fixing std.string

2010-08-20 Thread Ezneh
There's also this in std.string which requires a fix : http://d.puremagic.com/issues/show_bug.cgi?id=4673

Re: Fixing std.string

2010-08-20 Thread Andrei Alexandrescu
Russel Winder wrote: On Fri, 2010-08-20 at 02:22 +, dsimcha wrote: [ . . . ] 1. How did it get to be this way? Why did it seem like a good idea at the time to only support UTF-8 and only immutable strings? But isn't the thinking these days that immutable strings are a good thing?

Re: Fixing std.string

2010-08-20 Thread Andrei Alexandrescu
Ezneh wrote: There's also this in std.string which requires a fix : http://d.puremagic.com/issues/show_bug.cgi?id=4673 Sure. On the face of it, I think isNumeric is a silly function because the effort expended on doing a good prediction is almost the same as doing the actual conversion - so

Re: Fixing std.string

2010-08-20 Thread Jonathan M Davis
On Thursday 19 August 2010 23:27:33 Russel Winder wrote: On Fri, 2010-08-20 at 02:22 +, dsimcha wrote: [ . . . ] 1. How did it get to be this way? Why did it seem like a good idea at the time to only support UTF-8 and only immutable strings? But isn't the thinking these days that

Re: Fixing std.string

2010-08-20 Thread bearophile
Andrei Alexandrescu: Sure. On the face of it, I think isNumeric is a silly function because the effort expended on doing a good prediction is almost the same as doing the actual conversion - so why not just try it. The difference is that a well designed isNumeric doesn't need to use

Re: Fixing std.string

2010-08-20 Thread Andrei Alexandrescu
On 08/20/2010 07:21 AM, bearophile wrote: Andrei Alexandrescu: Sure. On the face of it, I think isNumeric is a silly function because the effort expended on doing a good prediction is almost the same as doing the actual conversion - so why not just try it. The difference is that a well

Re: Fixing std.string

2010-08-20 Thread bearophile
bearophile Wrote: The difference is that a well designed isNumeric doesn't need to use exceptions, A possible design is to use only one template function, like: private auto _realConvert(bool useExepions)(string txt) { ... if (some_error_condition) { static if (useExcepions)

Re: Fixing std.string

2010-08-20 Thread Ezneh
Andrei Alexandrescu Wrote: I guess return collectException(to!real(input)) is null; should be a fine replacement for isNumeric. Andrei I found another way to improve the isNumeric function. I'm doing it with a (ugly) regular expression but it works very well but maybe we

Fixing std.string

2010-08-19 Thread dsimcha
As I mentioned buried deep in another thread, std.string is in serious need of fixing, for two reasons: 1. Most of it doesn't work with UTF-16/UTF-32 strings. 2. Much of it requires the input to be immutable even when there's no good reason for this constraint. I'm trying to understand a few

Re: Fixing std.string

2010-08-19 Thread Andrei Alexandrescu
On 08/19/2010 09:22 PM, dsimcha wrote: As I mentioned buried deep in another thread, std.string is in serious need of fixing, for two reasons: 1. Most of it doesn't work with UTF-16/UTF-32 strings. 2. Much of it requires the input to be immutable even when there's no good reason for this