Re: Request Feedback for Instance Variable Sugar RFC
| From: | Stelian Mocanita | Date: | Mon, 09 Mar 2015 14:37:46 +0000 |
| Subject: | Re: Request Feedback for Instance Variable Sugar RFC | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84478@lists.php.net to get a copy of this message | ||
On top of the cultural disposition, there is also the fact that things
should not be removed from the language without deprecating them, so at
best 7.0 would emit and E_DEPRECATED for the usage of "@".
- Stelian
On Mon, Mar 9, 2015 at 3:31 PM, Kalle Sommer Nielsen <kalle@php.net> wrote:
> Hi
>
> 2015-03-09 15:11 GMT+01:00 Shawn McCool <shawn@heybigname.com>:
> > I guess that if I thought that PHP would change its scoping, I would have
> > tried for that.
>
> Well take this code into consideration:
> <?php
> class A {
> protected $b;
>
> function c($b) {
> $b = $b; // does not work
> }
>
> function d($d) {
> $b = $d; // works
> }
> }
> ?>
>
> A::c() will fail because the parameter $b conflicts with the property
> A::$b, but example works because the parameter is now named $d, and
> therefore making $b available for assignment (should probably
> internally be implemented as a reference to $this->b), but only on
> demand (JIT) to avoid extra memory consumption.
>
> This approach may seem quirky at first, but it doesn't add any new
> syntax but some magic behind the scenes. Although I personally am not
> a huge fan of magic variables like that, it is possible.
>
>
>
> --
> regards,
>
> Kalle Sommer Nielsen
> kalle@php.net
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>