changing "$this" into "this" is not an option. This would break 90% of PHP code 
:)
________________________________________
From: Marc Bennewitz <dev@mabe.berlin>
Sent: Tuesday, May 24, 2016 10:21:02 PM
To: internals@lists.php.net
Subject: Re: [PHP-DEV] [RFC] Fix inconsistent behavior of $this variable

On 05/24/2016 11:57 AM, Rowan Collins wrote:
> On 24/05/2016 06:45, Jesse Schalken wrote:
>> I'm curious, what is it about $this that makes it special in the first
>> place? Can't it be a normal local variable that happens to already be
>> assigned at the start of a method?
>
> There are a few things that take advantage of its specialness, e.g.
>
> - binding a closure to an object changes the meaning of $this in a way
> very different from assigning it into scope with "use($this)"
> - a method declared static can detect and throw errors on anything
> referencing $this
> - when calling parent::foo() from an instance method, the value of
> $this needs to be set appropriately on the new method; being able to
> reassign $this could lead to some odd behaviour there
>
> Python's approach is certainly valid, and leads to some different
> useful properties, I'm sure, but it's a very different design, not
> just a more relaxed attitude to assignment.

As of $this is a very special variable where only the engine is (or
should) be allowed to change.
I would like to ask you if it wouldn't be better to NOT define $this as
a special variable
including a lot of code to make sure this variable doesn't get re-assigned
but instead define this as a keyword like self where the syntax makes
sure it can't be re-assigned
and it's less special and simpler to learn for beginners.

I know it would be a huge BC break but for me it sounds more "right" and
could also be introduced
in parallel to $this for a long long time but without a lot of
overplayed code for $this.

Thanks,
Marc

>
> Regadrds,


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


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

Reply via email to