Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19029 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45193 invoked by uid 1010); 16 Sep 2005 06:51:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45178 invoked from network); 16 Sep 2005 06:51:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2005 06:51:53 -0000 X-Host-Fingerprint: 195.225.34.5 fw01.axit.nl Received: from ([195.225.34.5:8544] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 42/2F-43379-98B6A234 for ; Fri, 16 Sep 2005 02:51:53 -0400 Message-ID: <42.2F.43379.98B6A234@pb1.pair.com> To: internals@lists.php.net References: <42FCE0E4.604@lerdorf.com> <43281520.4000209@metropolis-ag.de> <4E.EA.41173.2CBB9234@pb1.pair.com> <4329DEBE.3080204@php.net> Date: Fri, 16 Sep 2005 08:49:22 +0200 Lines: 50 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Posted-By: 195.225.34.5 Subject: Re: [PHP-DEV] PHP 6.0 Wishlist From: r.korving@xit.nl ("Ron Korving") 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" schreef in bericht news:4329DEBE.3080204@php.net... > 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