Re: [RFC] Nullable Types

From: Date: Wed, 20 Apr 2016 18:28:17 +0000
Subject: Re: [RFC] Nullable Types
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-92563@lists.php.net to get a copy of this message
On Wed, Apr 20, 2016 at 11:55 AM, Jesse Schalken <me@jesseschalken.com> wrote: > 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.

« previous php.internals (#92563) next »