From: kasal@... (Stepan Kasal) Date: 2002-07-10T17:48:48+09:00 Subject: Re: String#split converts string args to regexes -- ? Hallo Matz, On Tue, 09 Jul 2002 16:35:03 GMT, Yukihiro Matsumoto wrote: > > sub/gsub > > (a) prohibit string pattern > (b) string patterns as strings, without converting into regex. > > split > > (c) prohibit string pattern longer than 1. > (d) string patterns as strings, without converting into regex. > > The meaningful consistent combination must be a-c and b-d. Which do > you prefer? [BTW: I wasn't able to express my ideas so simply and clearly, thanks!] I've also considered a-d. I wouldn't say it's inconsistent: sub/gsub require a regexp, split accepts either a regexp or a string. (And I was afraid that you'd refuse (b) because it changes behaviour of existing correct programs, which is worse then making them incorrect.) But there were voices saying that (b) would be useful, since escaping may be complicated. But alternatively, you could provide something like Regexp.new_const(s) which would create a regexp matching string s (ie. no character is interpreted as meta character). (I don't know whether `new_const' is a good name, perhaps `new_string' or even the shorter `new_s'.) The above would enable a-d or even a-c. Sesitively written error messages would direct people to express exactly what they want. It will annoy more people then switching to b-d but it'll annoy them less---it might be frustrating to discover (after hours of debugging code which used to work) that Matz has changed the definition of sub/gsub. In other words, error messages are better then weird behaviour, even in an interpreted language. So, there are IMHO three possibilities: (1) a-c with Regexp.new_const (2) a-d with Regexp.new_const (3) b-d I'd be happy with any of these but I prefer (1). Stepan