Re: Re: Allowing is_* functions to accept multiple parameters
| From: | Leigh | Date: | Thu, 19 Sep 2013 09:10:23 +0000 |
| Subject: | Re: Re: Allowing is_* functions to accept multiple parameters | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-69228@lists.php.net to get a copy of this message | ||
On 19 September 2013 03:20, William Bartlett
<william.a.bartlett@gmail.com> wrote:
> I would argue that LTR support is also inconsistent / not desired.
>
> If I wrote:
>
> $i = 0;
> is_three($i = $i + 1, $i = $i + 1, $i = $i + 1);
>
> I would certainly expect is_three to return false, but I would also expect
> $i to contain three. php doesn't normally evaluate arguments lazily, it
> would be weird for that behavior to suddenly crop up. users who want lazy
> evaluation can write it the traditional way (with &&).
I think there has been some misunderstanding of my intention here
(maybe I communicated it badly) - Originally I was pretty confused
when reading Bobs response as it was way beyond the scope of what I
was proposing.
When I say parameters evaluated LTR / boolean short-curcuit evaluation
I mean it like this:
$i = 1;
$f = 1.1;
is_int($i, $f, $i, $i) => is_int(1) && is_int(1.1) && is_int(1) &&
is_int(1)
is_int($i++, $f++, $i++, $i++) => is_int(1) && is_int(1.1) &&
is_int(2) && is_int(3)
$i == 4;
$f == 2.1;
Internally, processing will stop at the is_int(1.1) and not bother
continuing to check the types of further arguments.
I did not mean:
is_int($i++, $f++, $i++, $i++) => is_int($i++) && is_int($f++) &&
is_int($i++) && is_int($i++)
As Bob said, this would take some pretty nuts opcode processing, and
is completely not worth the effort involved. I may have emphasised a
parallel with isset() a bit too much, however isset() cannot take
expressions as input.
I was never intending to try and evaluate parameters as they were
passed and jump over subsequent evaluations. Standard function call
semantics would still apply. I hope that people find that less
confusing / unexpected.