Re: [RFC] [VOTE] Typed properties v2
| From: | Christoph M. Becker | Date: | Sun, 23 Sep 2018 20:50:43 +0000 |
| Subject: | Re: [RFC] [VOTE] Typed properties v2 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103241@lists.php.net to get a copy of this message | ||
On 23.09.2018 at 22:07, Rowan Collins wrote:
> On 23/09/2018 19:41, Claude Pache wrote:
>>
>>> 3) Object properties may be type hinted and the class author has
>>> until the end
>>> of the constructor to make sure they're fulfilled, otherwise
>>> TypeError on the
>>> spot (what I'm proposing).
>> Just to be sure you don’t miss the herd that this elephant is concealing:
>>
>> In addition, you *must* forbid unset() on those properties...
>
> We "must" forbid this IF we aim to guarantee that the object never has
> uninitialised properties; but the current consensus is that we can't
> make such a guarantee without changing a lot of other parts of the
> language.
>
> There are strong feelings that unset should be available for use in
> lazy-initialisation hacks, so this is likely to remain one of the
> back-doors which will let elephants in, unless and until someone comes
> up with a replacement for that hack.
In my opinion, explicitly *declared* properties should not be
unsettable. We don't allow to undefine constants, functions, classes
etc. either. Adding and removing other properties could still be allowed.
--
Christoph M. Becker