Re: Introducing "Array Of" RFC

From: Date: Sun, 19 Jan 2014 22:02:34 +0000
Subject: Re: Introducing "Array Of" RFC
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-71280@lists.php.net to get a copy of this message
> However, I have but one little issue with the HHVM syntax. Why is the ? > before the type name? I much prefer the C#-style Bar? to this confusing > ?Bar. I suppose this is only a minor issue, though. > Two reasons come to mind, both essentially aesthetic: * Symbol crowding: function foo(array? &$bar) { } bar by ref expects array, but may take null (which is perfectly common for a by-ref variable). Trouble is, '? &$' is starting to look perlish. * Generic expansion: Prefix: function foo(?array<Bar<?int>> $baz)... Suffix: function foo(array<Bar<int?>>? $bar)... Both proclaim a nullable array of non-nullable Bar objects of nullable type int. The prefix version makes it much more obvious which '?' goes with which portion of the type structure. function foo(array?<Bar<int?>> $baz)... sounds tempting, but some shift/reduce conflicts start to emerge out of that stacking of tokens. Resolvable, of course, but complicating the parser rules over a bit of aesthetics like that.... You can't see it, but I've got my frownie face on right now. -Sara P.S. - I'm not voting for or against anything at this point either. Just offering input during discussion phase, as we're all meant to. :)

« previous php.internals (#71280) next »