rfc:lexical-anon
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:lexical-anon [2016/04/20 06:44] – krakjoe | rfc:lexical-anon [2016/04/20 06:51] – krakjoe | ||
---|---|---|---|
Line 78: | Line 78: | ||
It has been suggested that it would be better to have [use(...)] on each function declaration. This would lead to a lot of repetition, and fragmented code that is more difficult to reason about. | It has been suggested that it would be better to have [use(...)] on each function declaration. This would lead to a lot of repetition, and fragmented code that is more difficult to reason about. | ||
+ | |||
+ | Another suggestion made is to allow symbols inline, so that the following code is legal: | ||
+ | |||
+ | <code php> | ||
+ | class { | ||
+ | public $prop = $var; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This has some appealing advantages, such as using expression to initialize properties. But it also raises huge inconsistencies, | ||
+ | |||
+ | <code php> | ||
+ | class { | ||
+ | public $prop = new Foo(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Be allowed, while not allowing the same thing in normal classes. | ||
+ | |||
+ | Additionally, | ||
+ | |||
+ | <code php> | ||
+ | class { | ||
+ | public $prop = & | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | This is almost literally backwards. | ||
+ | |||
+ | If we are going to allow expressions for anonymous classes that we do not allow for normal classes, then it is better to leave that for another RFC. | ||
+ | |||
+ | What we are doing is only importing symbols, we don't //need// to invent a new way to initialize them. | ||
The cognitive overhead of " | The cognitive overhead of " |
rfc/lexical-anon.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1