http://d.puremagic.com/issues/show_bug.cgi?id=5977
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |[email protected] AssignedTo|[email protected] |[email protected] --- Comment #3 from [email protected] 2012-10-22 02:52:16 PDT --- (In reply to comment #0) > This D2 program seems to go in infinte loop (dmd 2.053beta): > > > import std.string; > void main() { > split("a test", ""); > } > > ------------------------ > > My suggestion is to add code like this in std.array.split(): > > if (delim.length == 0) > return split(s); > > This means that en empty splitting string is like splitting on generic > whitespace. This is useful in code like: > > auto foo(string txt, string delim="") { > return txt.split(delim); > } I think it is a bad idea on two counts: 1. If the user wanted that behavior, he'd have written it as such. If the user actually passed a seperator that is an empty range, he probably didn't mean for it split by spaces. 2. I think it would also bring a deviation of behavior between strings and non-strings. Supposing r is empty: * "hello world".split(""); //Ok, split white * [1, 2].split(r); //Derp. (In reply to comment #1) > Alternative: throw an ArgumentError("delim argument is empty") exception if > delim is empty. I *really* think that is a *much* saner approach. Splitting with an empty separator is just not logic. Trying to force a default behavior in that scenario is wishful thinking (IMO). I think it should throw an error. I'll implement this. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
