Re: Strict switch statements

From: Date: Thu, 14 Jun 2018 05:26:27 +0000
Subject: Re: Strict switch statements
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-102252@lists.php.net to get a copy of this message
Hi, On Thu, Jun 14, 2018 at 7:53 AM, Sara Golemon <pollita@php.net> wrote: > Just for casual discussion at this point: > https://github.com/php/php-src/pull/3297 > > switch ($a) { > case FOO: > // Works exactly as current behavior. > break; > case == FOO: > // Nearly identical, though not using the ZEND_CASE optimization. > // Can probably make this equivalent to case FOO, but it > felt > like an interesting direction. > break; > case === FOO: > // Only triggers if $a === FOO, no type juggling > break; > } > > Love it? Hate it? See obvious flaws? The implementation is just a > rushed proof of concept, not something I've labored over, it may well > have bugs. Certainly wouldn't target anything earlier than 7.4, if at > all. > I love it for the === part. Countless times I've had to avoid switch statements because they can't do strict comparisons. Cheers, Andrey.

« previous php.internals (#102252) next »