Benas,

> On May 15, 2020, at 04:33, Benas IML <benas.molis....@gmail.com> wrote:
> 
> Hey,
> 
> `guard` would be a keyword this means that all of the classes, interfaces and 
> traits named Guard would be illegal. Therefore Laravel's `Guard` interface 
> would be incompatible with PHP 8 which in turn means thousands of web 
> applications would be too.
> 
> Best regards,
> Benas Seliuginas


If the parser were sufficiently smart, I don't think 'guard' would actually 
conflict with a class or function named 'guard'. If the syntax were:

        guard (EXPRESSION) else STATEMENT_OR_BLOCK

then, 'guard' could not conflict with a class name, because there's no existing 
syntax that would fit the pattern of a type name followed by a parenthesis — 
you can't call a type name as if it were a function. Even if you could, it 
would still not conflict with a function call, because the 'else' keyword after 
the close parenthesis would not be valid syntax immediately following a 
function call.

So the main question there is, is the parser sufficiently smart to be able to 
see 'guard' and look ahead for the 'else' to disambiguate a function call from 
a guard statement?

-John

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to