Re: [VOTE] Shorter Attribute Syntax Change

From: Date: Mon, 10 Aug 2020 13:33:38 +0000
Subject: Re: [VOTE] Shorter Attribute Syntax Change
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-111427@lists.php.net to get a copy of this message
On 10.08.20 15:08, Benjamin Eberlei wrote:
() does not count as ending symbol, because it is not required, as such its not an ending symbol. The point Andreas Leathley makes in the discussion thread about new Foo not having an end symbol demonstrates exactly the opposite point he was trying to make, because the new statement itself has to end with a semicolon: new Foo(); new Foo; A statement has an ending symbol semicolon.
While I don't know the exact internal semantics of PHP, according to my grasp of the language the new keyword does not need a semicolon at the end - it can be part of any expression, like "new Foo(new Bar);". According to the PHP manual (https://www.php.net/manual/en/language.basic-syntax.instruction-separation.php) instructions in PHP need to be terminated with a semicolon, while "new" as a keyword has no special requirement about a starting or ending delimiter. The point I was trying to make was that new and attributes have the same requirements in that they both need a class name and then optionally arguments for the constructor to that class, so they are both narrow in terms of what they do, attributes even more so than new, which reduces the helpfulness of delimiters as you cannot define arbitrary instructions in attributes - it always starts off with a class and then any possibly more complex instructions will be in the arguments, and those are enclosed by ().

« previous php.internals (#111427) next »