# [RFC] Pre-vote notice for Nullable Types

- Thread: https://externals.io/message/93100
- Original archive: https://news-web.php.net/php.internals/93100
- Started by Levi Morrison on 2016-05-06T19:41:00+00:00
- Messages: 7
- RFC: Nullable Types (Implemented (PHP 7.1)) — https://externals.io/rfc/nullable_types.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #93100 — Levi Morrison — 2016-05-06T19:41:00+00:00

URL: https://externals.io/message/93100#93100

The [RFC for Nullable Types][1] is going to go into the voting phase
soon. There have been a few changes to the RFC in the meantime:

  - More example for documentation's sake
  - The vote is now split into two parts: one for nullable parameter
types and one for nullable return types.
  - Updated BC break section. This RFC now contains the fix for [bug
71428][2] that was previously committed. [More information][3] can be
found in the RFC.
  - Coauthored with Dmitry Stogov.

Unless there are significant concerns raised this will go into voting
phase early next week.

  [1]: https://wiki.php.net/rfc/nullable_types
  [2]: https://bugs.php.net/bug.php?id=71428
  [3]: https://wiki.php.net/rfc/nullable_types#to_backward_compatibility

---

## #93106 — Tom Worster — 2016-05-07T15:31:44+00:00

URL: https://externals.io/message/93100#93106 · In reply to: #93100

> The [RFC for Nullable Types][1] is going to go into the voting phase
> soon. There have been a few changes to the RFC in the meantime:
>
>    - More example for documentation's sake
>    - The vote is now split into two parts: one for nullable parameter
> types and one for nullable return types.

The vote counting surprises me. Say, for the sake of argument, a 
hypothetical nullable returns RFC were to pass with 2/3. After that a 
2nd hypothetical RFC for nullable parameters goes to vote. This 2nd RFC 
would need 2/3 to pass. Your RFC defines the same two separate language 
changes as two votes but one of them requires only a majority.

Also, could you clarify in the RFC text how the voting works. For 
example, is it the case that the entire nullable parameter vote is 
discarded if the nullable return vote does not pass?

Tom

---

## #93107 — Levi Morrison — 2016-05-07T16:06:13+00:00

URL: https://externals.io/message/93100#93107 · In reply to: #93106

> 
> > […]
>
>
> The vote counting surprises me. Say, for the sake of argument, a
> hypothetical nullable returns RFC were to pass with 2/3. After that a 2nd
> hypothetical RFC for nullable parameters goes to vote. This 2nd RFC would
> need 2/3 to pass. Your RFC defines the same two separate language changes as
> two votes but one of them requires only a majority.
>
> Also, could you clarify in the RFC text how the voting works. For example,
> is it the case that the entire nullable parameter vote is discarded if the
> nullable return vote does not pass?
>
> Tom

Dmitry is the one who wanted the split vote, so I will defer the answer to him.

---

## #93108 — Nikita Popov — 2016-05-07T17:19:10+00:00

URL: https://externals.io/message/93100#93108 · In reply to: #93106

> 
>
> > […]
>
> The vote counting surprises me. Say, for the sake of argument, a
> hypothetical nullable returns RFC were to pass with 2/3. After that a 2nd
> hypothetical RFC for nullable parameters goes to vote. This 2nd RFC would
> need 2/3 to pass. Your RFC defines the same two separate language changes
> as two votes but one of them requires only a majority.
>
> Also, could you clarify in the RFC text how the voting works. For example,
> is it the case that the entire nullable parameter vote is discarded if the
> nullable return vote does not pass?
>
> Tom
>

This RFC has one primary vote and one secondary vote. The primary vote
determines whether we want to add nullable types to our type system. The
secondary vote decides how precisely this will happen, in this instance
deciding whether nullable types will be restricted to return types only or
not. This is a standard voting layout, with precedent in a number of other
RFCs.

The reason why the second vote must use a 1/2 majority is symmetry. You, as
somebody who does not like nullable parameter types, argue from a
perspective of one 2/3 majority RFC for introducing nullable returns and
another 2/3 majority RFC for introducing nullable params. I, as somebody
who thinks supporting this syntax only for returns is wildly inconsistent,
will argue from a perspective of a 2/3 majority RFC for introducing
nullable *types* and another 2/3 majority RFC for restricting them to
return types only. Depending on the perspective this would require either a
2/3 majority, or a 1/3 "majority" for unrestricted nullable types. Using a
1/2 majority vote ensures that there is no bias for either choice.

Regards,
Nikita

---

## #93110 — bjorn.x.larsson@telia.com — 2016-05-08T10:07:31+00:00

URL: https://externals.io/message/93100#93110 · In reply to: #93100

Den 2016-05-06 kl. 21:41, skrev Levi Morrison:

> The [RFC for Nullable Types][1] is going to go into the voting phase
> soon. There have been a few changes to the RFC in the meantime:
>
>    - More example for documentation's sake
>    - The vote is now split into two parts: one for nullable parameter
> types and one for nullable return types.
>    - Updated BC break section. This RFC now contains the fix for [bug
> 71428][2] that was previously committed. [More information][3] can be
> found in the RFC.
>    - Coauthored with Dmitry Stogov.
>
> Unless there are significant concerns raised this will go into voting
> phase early next week.
>
>    [1]: https://wiki.php.net/rfc/nullable_types
>    [2]: https://bugs.php.net/bug.php?id=71428
>    [3]: https://wiki.php.net/rfc/nullable_types#to_backward_compatibility
>
Nice, look forward to the voting even if I don't have one ;) Would it be
possible to include the earlier example "binary tree" in Introduction? I
think it served as one good UC why this feature is needed. I also think
one could expand the reference section with some of the ones from:
- https://wiki.php.net/rfc/nullable_return_types#references

Regards //Björn Larsson

---

## #93111 — Tom Worster — 2016-05-08T13:54:11+00:00

URL: https://externals.io/message/93100#93111 · In reply to: #93108

>This RFC has one primary vote and one secondary vote. The primary vote
>determines whether we want to add nullable types to our type system. The
>secondary vote decides how precisely this will happen, in this instance
>deciding whether nullable types will be restricted to return types only
>or not. This is a standard voting layout, with precedent in a number of
>other RFCs.
>
>The reason why the second vote must use a 1/2 majority is symmetry. You,
>as somebody who does not like nullable parameter types, argue from a
>perspective of one 2/3 majority RFC for introducing nullable returns and
>another 2/3 majority RFC for introducing nullable params. I, as somebody
>who thinks supporting this syntax only for returns is wildly
>inconsistent, will argue from a perspective of a 2/3 majority RFC for
>introducing nullable *types* and another 2/3 majority RFC for restricting
>them to return types only. Depending on the perspective this would
>require either a 2/3 majority, or a 1/3 "majority" for unrestricted
>nullable types. Using a 1/2 majority vote ensures that there is no bias
>for either choice.

The explanation is very clear. Thank you.

Tom


(Btw, I don't disagree about the inconsistency you mentioned. But I don't
think it's a wild inconsistency, rather a justified one, given our
context.)

---

## #93112 — Nikita Popov — 2016-05-08T14:33:13+00:00

URL: https://externals.io/message/93100#93112 · In reply to: #93111

> 
>
> > […]
>
> The explanation is very clear. Thank you.
>
> Tom
>
>
> (Btw, I don't disagree about the inconsistency you mentioned. But I don't
> think it's a wild inconsistency, rather a justified one, given our
> context.)
>

At this point in time, with the current state of our type system, I agree
that this is not a wild inconsistency.

However, the type system is expanding. Typed properties are already under
discussion, and they would certainly support nullable types (in fact, the
proposal is currently blocked by us not having them yet). Generics are also
already under discussion (though far removed from a viable implementation).
They would, presumably, also support nullable types as generic type
parameters (or at least I don't see why not). Following this trend, we'd
end up in a situation where nullable types are supported *everywhere* --
apart from parameters.

Which is in my eyes a pretty bad spot to be in. At that point we'd have
gone from this being a "nullable return types" feature to a "nullable
types, but not allowed in parameters" feature, which is just weird.

Example for nullable types used in all of return types, parameter types and
property types.

class Node {
    private ?Node $left;
    private ?Node $right;
    private $value;
    public function __construct(?Node $left, ?Node $right, $value) {
        $this->left = $left;
        $this->right = $right;
        $this->value = $value;
    }
    public function getLeft() : ?Node {
        return $this->left;
    }
    public function getRight() : ?Node {
        return $this->right;
    }
    public function setLeft(?Node $node) {
        $this->left = $node;
    }
    public function setRight(?Node $node) {
        $this->right = $node;
    }
    // ...
}

Not having nullable types in parameters here would require you to either
drop the type altogether, or allow $node->setLeft() (eeeek), or
differentiate between $node->setLeft($nonNullNode) and $node->unsetLeft(),
which tends to be ugly for use in algorithmic transformations.

Regards,
Nikita
