#30845 [Opn->WFx]: add "in" operator to test for inclusion

From: Date: Sat, 20 Nov 2004 00:55:51 +0000
Subject: #30845 [Opn->WFx]: add "in" operator to test for inclusion
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69288@lists.php.net to get a copy of this message
ID: 30845 Updated by: derick@php.net Reported By: phpbugs at eire dot ca -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: FreeBSD PHP Version: 5.0.2 New Comment: in_array in combination with range() does the same. We will not add more syntax for this. Derick Previous Comments: ------------------------------------------------------------------------ [2004-11-19 22:36:13] jed at jed dot bz The ellipsis operator is unnecessary due to the existence of the range() function. true == 5 in range(1, 10); The in operator, in my opinion, is unnecessary and is only syntactic sugar due to the existence of in_array(). I don't like S.S. operators (I opposed instanceof et. al., as well as "and" as an alternative to &&). In the long run, syntactic sugar makes code more difficult to read and just adds more passes in the parser. PHP at its root isn't BASIC. It's nice functionality, I agree, but there's a lot more that could be done to the language to make it more like VB. And that's not a good path to start down. ------------------------------------------------------------------------ [2004-11-19 22:29:03] phpbugs at eire dot ca Description: ------------ Some languages such as SQL or (cough)Visual Basic(cough) include an "in" operator to test for inclusion in a given range of values. SQL uses an explicit list of values like so: SELECT s1 FROM t1 WHERE s1 IN (SELECT s1 FROM t2); Or an even simpler example: SELECT 'foo' IN ('foo','bar','foobar'); Visual Basic makes it even better by adding the ellipsis operator: if iBar in (25..40) then This would be a great addition to PHP, with or without the ellipsis operator. It would be especially useful for switch statements. And if you could pass it an array, I'd be in heaven! ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30845&edit=1

« previous php.bugs (#69288) next »