The problem with this would be that it can't be decided on a per-case basis, but only for the whole switch, which would make the execution slower. That's why I'd prefer a "regcase", but I guess this can be considered ugly becuase e.g. C(++) doesn't have a "regcase" either and it's quite a diversion from the known syntax.
Ron "Hartmut Holzgraefe" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > Ron Korving wrote: > > I have another idea I came up with today: regular expression switches, but > > it would be difficult without adding to the syntax. > > no, its actually pretty easy from a syntax point of view, > you don't need to add another keyword, just add an optional > callback parameter to switch() which is a comparison function > similar to what you pass to e.g. usort() > > that way you are not limited to one type of reges but could > have ereg or preg style or could do other things like case > insensitive switches: > > switch ($str, "ereg") { > case "[[:alpha:]]+":... > } > > switch ($str, "preg_match") { > case "/^[A-Za-z]+$/": ... > } > > switch ($str, "strcasecmp") { > ... > } > > or even > > function my_cmp($str1, $str2) { > return strcmp(str_rev($str1, $str2)); > } > > switch ($str, "my_cmp") ... > > > i have looked into implementing that quite a while ago > but hat to give up due to lack of time and understanding > at that point in time though -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php