Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71281 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68923 invoked from network); 19 Jan 2014 22:19:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2014 22:19:58 -0000 X-Host-Fingerprint: 188.29.165.115 188.29.165.115.threembb.co.uk Received: from [188.29.165.115] ([188.29.165.115:14100] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/F1-61840-C8F4CD25 for ; Sun, 19 Jan 2014 17:19:56 -0500 To: internals@lists.php.net,Sara Golemon Message-ID: <52DC4F86.6030000@php.net> Date: Sun, 19 Jan 2014 22:19:50 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 References: <52DC125C.4010609@ajf.me> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 188.29.165.115 Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: krakjoe@php.net (Joe Watkins) On 01/19/2014 10:02 PM, Sara Golemon wrote: >> 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> $baz)... > Suffix: function foo(array>? $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?> $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. :) > Sara, In the original internals thread about generics, you mention that the HHVM team were going to donate their effort and patch to PHP so we could have generics in PHP .... so ... how did that work out, is there a patch (even a half finished one) ?? I'm a bit disappointed that this has been turned into a conversation about something I see as completely different. I wasn't looking to introduce a paradigm, and think it would be quite terrible to use the syntax for generics for this; I only want to hint for generics when I can program with generics, and even if I wrote the patch next week, the original conversation made it seem like it would never be merged anyway ... Was there some technical difficulty that stopped the work on generics when it was first brought up, or did you just realise that it would never get through ?? Original conversation about generics: http://php.markmail.org/message/fhqgkzyui3cpantg?q=net%2Ephp%2Elists%2Einternals+generics+order:relevance&page=1 Cheers Joe