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

Reply via email to