Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19008 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40050 invoked by uid 1010); 15 Sep 2005 20:51:35 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40034 invoked from network); 15 Sep 2005 20:51:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Sep 2005 20:51:35 -0000 X-Host-Fingerprint: 213.136.52.47 mailgate2.mysql.com Linux 2.5 (sometimes 2.4) (4) Received: from ([213.136.52.47:47054] helo=mailgate.mysql.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id C7/37-41173-5DED9234 for ; Thu, 15 Sep 2005 16:51:34 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate.mysql.com (8.13.4/8.13.4) with ESMTP id j8FKpSid008928; Thu, 15 Sep 2005 22:51:28 +0200 Received: from mail.mysql.com ([10.222.1.99]) by localhost (mailgate.mysql.com [10.222.1.98]) (amavisd-new, port 10026) with LMTP id 05698-06; Thu, 15 Sep 2005 22:51:27 +0200 (CEST) Received: from [192.168.20.47] ([212.8.198.137]) (authenticated bits=0) by mail.mysql.com (8.13.3/8.13.3) with ESMTP id j8FKpLm3016537 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Sep 2005 22:51:22 +0200 Message-ID: <4329DEBE.3080204@php.net> Date: Thu, 15 Sep 2005 22:51:10 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050704 SeaMonkey/1.0a MIME-Version: 1.0 To: Ron Korving CC: internals@lists.php.net References: <42FCE0E4.604@lerdorf.com> <43281520.4000209@metropolis-ag.de> <4E.EA.41173.2CBB9234@pb1.pair.com> In-Reply-To: <4E.EA.41173.2CBB9234@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailgate.mysql.com Subject: Re: [PHP-DEV] PHP 6.0 Wishlist From: hartmut@php.net (Hartmut Holzgraefe) 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