Re: Replace ugly attribute token #[] to other
| From: | Olle Härstedt | Date: | Wed, 23 Aug 2023 07:47:44 +0000 |
| Subject: | Re: Replace ugly attribute token #[] to other | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120924@lists.php.net to get a copy of this message | ||
2023-08-23 8:35 GMT+02:00, chopins xiao <chopins.xiao@gmail.com>:
> I use @ instead of #[] as attribute token. attribute use whitespace marks
> are closed. Of course you can start with @@ or #, other.
> error control use @@ instead of @, add T_SILENCE token
>
> new syntax:
> one attribute: @attribute{WHITESPACE} @otherAttribute(12){WHITESPACE}
> group attribute: @attribute1(1, 2),attribute2(343,
> 43)@attibute3(33)[WHITESPACE]
>
> current syntax:
> one attribute: #[attribute()] #[otherAttribute()]
> group attribute: #[attribute1(1, 2),attribute2(343,),attibute3(33)]
>
> below is comparison
> new syntax:
>
> @AttrA@AttrB(112, 334),AttrC
> @AttrD
> class A {
> @AttrE
> @AttrF @AttrG
> public $a;
> @AttrM
> public function m1(@AttrParma(1) $c) {}
> }
>
> $ab = @fn(1) fn()=> 1+2;
> -----------
> current syntax:
>
> #[AttrA,AttrB(112, 334),AttrC]
> #[AttrD]
> class A {
> #[AttrE]
> #[AttrF] #[AttrG]
> public $a;
> #[AttrM]
> public function m1(#[AttrParma(1)] $c) {}
> }
> $ab = #[fn(1)] fn()=>1+2;
>
> my implemented:
> https://github.com/chopins/php-src/tree/new-syntax/attribute
>
>
> Other new syntax implemented (Verification of feasibility) :
>
> https://github.com/chopins/php-src/blob/php-alternative-syntax/alternative-syntax.md
>
>
> Regards
> Chopin Xiao
>
I think this was debated extensively already. :) It's unlikely to change.
Olle