On 24/05/2016 20:21, Marc Bennewitz wrote:
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.

It's an interesting concept, but most of the time $this *does* behave like a variable - it's not just a way of accessing scope like "self". You can write "foo($this)", "$bar = $this", even "echo $this" (if __toString is defined). So any syntax that made it look unlike a variable would have the opposite learning problem - how come I can use it like a variable, but it looks like something else?

There's also rather a shortage of syntax that doesn't already mean something...

Regards,

--
Rowan Collins
[IMSoP]


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

Reply via email to