On 5/13/11 12:10 PM, KennyTM~ wrote:
On May 13, 11 12:14, Ary Manzana wrote:
On 5/12/11 6:42 PM, KennyTM~ wrote:
On May 12, 11 19:13, Matthew Ong wrote:
Hi All,
Anyway to include this cool feature of switch with D in the near
future?
Why the obsession with 'switch'? 'if' works fine.
switch(str){
// regexp
case "abc", "def", "as+b?": s1(); break;
case "za+", "wd?", "aaa": s2(); break;
default: s3();
}
Regex isn't even a built-in feature, why would a 'switch' should support
it.
How about making regex a built-in feature with this syntax: /regex/ ?
I didn't use regex a lot before I started using Ruby. The thing is, in
Ruby it's so easy to use regex that I just started using them a lot more
than before. Of course, ruby has built-in operators for matching regexs,
so maybe that should also be added to the language (it's the =~
operator, but in D it should be a different one.)
IIRC it was once there, but very soon removed in the 0.x era (can't find
that changelog). You can't distinguish between division and regex
literal in the parser with this syntax.
Ruby can do it. I'm a happier programmer this way. If you don't support
it in the language the compiler is happy and the user is sad. :-( But
the user is more important than the compiler...