Re: PHP 6.0 Wishlist

From: Date: Thu, 15 Sep 2005 20:51:10 +0000
Subject: Re: PHP 6.0 Wishlist
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-19008@lists.php.net to get a copy of this message
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

Thread (327 messages)

« previous php.internals (#19008) next »