Re: [RFC] Nullable Types
| From: | Lin Yo-An | Date: | Thu, 21 Apr 2016 11:00:06 +0000 |
| Subject: | Re: [RFC] Nullable Types | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-92590@lists.php.net to get a copy of this message | ||
On Wed, Apr 20, 2016 at 11:05 PM, guilhermeblanco@gmail.com <
guilhermeblanco@gmail.com> wrote:
>
> Dmitry is even involved in the discussion of having IS_UNDEF until
> constructor ends, then enforcing type hinting at the end of constructor to
> trigger potential invalid instance state. It created a mess in the internal
> structure by creating a 3-state value: uninitialized, absent of value
> (null) and assigned value. All this problem would be solved by merging null
> into accepted value.
> So far the proposed solution there to take a wrong assumption to assume a
> default value based on type defined (like int = 0, string = '', etc), which
> are all potential valid values, leading to unpredictable behavior if a
> develop misses to assign a value to that property.
>
> Sure, people will say that now PHP will require a NullPointerException,
> PHP is turning into Java, or that I don't know what I'm talking about
> because they coded for Amiga and I don't (yes, I've seen that already in
> this mailing list). But the fact is that keeping control of 3-state flags
> are hard to maintain.
>
I think this is not to make PHP like Java, and it totally makes sense -
Nullable should be a type of a type instead of a state. In Haskell it's
named Maybe or Option, and It's better than NullPointerException.
Here is a discussion from Haskell community:
https://mail.haskell.org/pipermail/haskell-cafe/2011-April/091269.html
--
Best Regards,
Yo-An Lin