As alluded to in an earlier email today1 I am now moving the
Nullable Types RFC2 to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.
There is a decision that needs to be made: does the question mark go
before or after the type name?
function (?Foo $foo);
function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC3.
I look forward to a helpful and meaningful discussion!
As alluded to in an earlier email today1 I am now moving the
Nullable Types RFC2 to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.
+1
The up to date implementation for return-type-hints may be found at
https://github.com/php/php-src/pull/1851/files
Implementation for argument-type-hints is really not a problem
There is a decision that needs to be made: does the question mark go
before or after the type name?function (?Foo $foo); function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC3.
It's better to use ? position before the type, to reduce fragmentation
with HHVM.
Thanks. Dmitry.
I look forward to a helpful and meaningful discussion!
The up to date implementation for return-type-hints may be found at
https://github.com/php/php-src/pull/1851/files
Splendid!
Thank you, Dmitry. I will refer to it in the nullable_returns RFC[1].
Tom
As alluded to in an earlier email today[1] I am now moving the
Nullable Types RFC[2] to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.There is a decision that needs to be made: does the question mark go
before or after the type name?function (?Foo $foo); function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC[3].
Please put it where HHVM puts it: in front of it. Other languages are
less of an issue than a syntax that's already used in a somewhat PHP
language.
As to the rest of the RFC: LGTM!
cheers,
Derick
As alluded to in an earlier email today[1] I am now moving the
Nullable Types RFC[2] to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.There is a decision that needs to be made: does the question mark go
before or after the type name?function (?Foo $foo); function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC[3].Please put it where HHVM puts it: in front of it. Other languages are
less of an issue than a syntax that's already used in a somewhat PHP
language.As to the rest of the RFC: LGTM!
I much prefer the "Nullable Foo" (?Foo) to "Foo or Null" (Foo?). I find it
easier to read.
However, I am not a fan of introducing both this and the "Null" type for
union types — this should be the only way to create nullable types. We
already have too many things that are possible in more than one way.
As it sits, this is purely syntactic sugar (when taken in tandem with union
types) and [if] we agree that it is good, then let us just forgo the other
syntax entirely. I'll add a little about that on the appropriate thread.
- Davey
As alluded to in an earlier email today[1] I am now moving the
Nullable Types RFC[2] to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.There is a decision that needs to be made: does the question mark go
before or after the type name?function (?Foo $foo); function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC[3].
Please put it where HHVM puts it: in front of it. Other languages are
less of an issue than a syntax that's already used in a somewhat PHP
language.As to the rest of the RFC: LGTM!
I much prefer the "Nullable Foo" (?Foo) to "Foo or Null" (Foo?). I find it
easier to read.However, I am not a fan of introducing both this and the "Null" type for
union types — this should be the only way to create nullable types. We
already have too many things that are possible in more than one way.As it sits, this is purely syntactic sugar (when taken in tandem with union
types) and [if] we agree that it is good, then let us just forgo the other
syntax entirely. I'll add a little about that on the appropriate thread.
- Davey
Also agree, the "nullable foo" reads better and has the advantage of
compatibility
with HHVM. The easier we make it for people to switch interpreters (and
develop
software which works on both interpreters) the better for PHP as a whole.
Also agree that we don't need null union types if we have nullable types.
- Matt
As alluded to in an earlier email today1 I am now moving the
Nullable Types RFC2 to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.There is a decision that needs to be made: does the question mark go
before or after the type name?function (?Foo $foo); function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC3.I look forward to a helpful and meaningful discussion!
I have to agree with the question mark in front after reading the
possible problems with the question mark as a suffix, the fact that HHVM
already puts it in front, and the argument to read it as "nullable type"
instead of "type or null". :)
+1
--
Richard "Fleshgrinder" Fussenegger
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC[3].
Another discussion reference ...
http://www.firebirdsql.org/manual/nullguide.html
http://www.firebirdsql.org/manual/nullguide-check-constraints.html adds
a little complexity to the validation case.
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
I read the RFC and it all sounds good to me. I appreciate the care taken to
ensure method compatibility rules are correct, a smooth interop with =null,
and to consider impact on union types if added later (? just becomes sugar).
I'm not sure if it's been mentioned or not, but the position of the ? has
impact on the ability to add a foo[] shorthand for generic arrays. Namely,
if the ? is at the start, then the syntax becomes ambiguous.
string[]? (nullable array of strings)
string?[] (array of nullable strings)
?string[] (ambiguous, need to consult precedence rules and/or use brackets)
I'm not sure how HHVM/Hack deals with that, or if it even has the foo[]
shorthand.
On Thu, Apr 14, 2016 at 1:42 PM, Levi Morrison morrison.levi@gmail.com
wrote:
As alluded to in an earlier email today1 I am now moving the
Nullable Types RFC2 to the discussion phase. In a nutshell this RFC
proposes syntax for declaring a type to alternatively be null.There is a decision that needs to be made: does the question mark go
before or after the type name?function (?Foo $foo); function (Foo? $foo);
There are precedents in several languages for each position. Some
relevant issues to where the question mark goes are noted in the
RFC3.I look forward to a helpful and meaningful discussion!
I read the RFC and it all sounds good to me. I appreciate the care taken to
ensure method compatibility rules are correct, a smooth interop with =null,
and to consider impact on union types if added later (? just becomes sugar).I'm not sure if it's been mentioned or not, but the position of the ? has
impact on the ability to add a foo[] shorthand for generic arrays. Namely,
if the ? is at the start, then the syntax becomes ambiguous.string[]? (nullable array of strings)
string?[] (array of nullable strings)
?string[] (ambiguous, need to consult precedence rules and/or use brackets)
I'm not sure how HHVM/Hack deals with that, or if it even has the foo[]
shorthand.
You would write array<?string>
; Hack doesn't have a short-hand syntax.