Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71156 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43839 invoked from network); 15 Jan 2014 21:24:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2014 21:24:37 -0000 Authentication-Results: pb1.pair.com header.from=pjsturgeon@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pjsturgeon@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.68 as permitted sender) X-PHP-List-Original-Sender: pjsturgeon@gmail.com X-Host-Fingerprint: 209.85.215.68 mail-la0-f68.google.com Received: from [209.85.215.68] ([209.85.215.68:52237] helo=mail-la0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/D9-26701-39CF6D25 for ; Wed, 15 Jan 2014 16:24:36 -0500 Received: by mail-la0-f68.google.com with SMTP id e16so445988lan.11 for ; Wed, 15 Jan 2014 13:24:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=T4OLwcZ3IF4/IDjca1WNoQKj2XApGd44/0rxqO2txJ4=; b=X6hBeyVGneu7H5X1glJbVuYEUKB1ncJeyaBNmwoScexCHzkUCKZXxr59t0KUgOWN/O JMkc+rKXKg5tdlyhN2gCHuW5tc2FSIlqEAvaYcrfcehL3ovmPgh74dMd6cP0ceo1N0Op ARbmnFzconz5X3njDaranSfAPpFTWfR47a9aLF9UQgRnddzxi9hdaOkjcCbXGLHEYyoZ dC6SE6gAHuJiGsD0GuyTaMnooHamE0r6T2S9GTmWHsN3cMSl25tlDcwwTqogkFdBYZ1R NUyzZN20FwZBeOMZcIH1u2N3kydH8cgqEurIywmPDq3PoC/HvckZqsboTIswlTgb7U+t r7DQ== MIME-Version: 1.0 X-Received: by 10.112.131.103 with SMTP id ol7mr103946lbb.72.1389821070502; Wed, 15 Jan 2014 13:24:30 -0800 (PST) Received: by 10.114.93.231 with HTTP; Wed, 15 Jan 2014 13:24:30 -0800 (PST) In-Reply-To: <002d01cf1234$01e6dc60$05b49520$@tutteli.ch> References: <001301cf1227$6d082ab0$47188010$@tutteli.ch> <002d01cf1234$01e6dc60$05b49520$@tutteli.ch> Date: Wed, 15 Jan 2014 16:24:30 -0500 Message-ID: To: Robert Stoll Cc: Marco Pivetta , Kristopher , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: pjsturgeon@gmail.com (Philip Sturgeon) On Wed, Jan 15, 2014 at 3:54 PM, Robert Stoll wrote: > > >> -----Original Message----- >> From: Marco Pivetta [mailto:ocramius@gmail.com] >> Sent: Wednesday, January 15, 2014 9:25 PM >> To: Kristopher >> Cc: Philip Sturgeon; Robert Stoll; internals@lists.php.net >> Subject: Re: [PHP-DEV] Introducing "Array Of" RFC >> >> On 15 January 2014 21:19, Kristopher wrote: >> >> > I think this implementation (MyClass[]) should be consistent this when >> > passing null. >> > >> >> Even without the argument of consistency, the new syntax would be pretty >> much useless if `NULL` was allowed, since every method would have start >> with a call to `array_filter`. >> >> Marco Pivetta >> > > You could also think in a different way. NULL is basically a valid entry = in an array. If you apply the restriction as implemented in the pull reques= t then one cannot use the new syntax for arrays which allow NULL, that seem= s odd to me as well. Especially since class/interface-types are reference t= ypes and I regard NULL as something equal to a null-pointer. > Furthermore, if one does not want to support NULL in an array currently, = then one probably already uses an own collection implementation which alrea= dy triggers and error, throws an exception respectively, when one tries to = add NULL to the collection. > > It seems the pull request does not yet support multidimensional arrays (e= .g. Foo[][]) but if we would stick to the restriction now then the conseque= nce should be that this restriction also applies to multi-dimensional array= s. In my opinion, we would spoil valid use cases this way for RFC and for f= uture ones (in the case multi-dimensional arrays will be introduced, other = concepts could be affected as well). > > Thus I would suggest to remove this check and provide a further SPL data = structure implementation instead which does not allow null as entry if this= feature is really needed. Seems more appropriate to me than making a restr= iction in the language itself. > > > I would assume that the majority of people will be using this syntax to ensure the types of objects. In English: "I would like everything in this array to be Foo." That is much more programatically useful in my opinion than: "I would like everything in this array to be Foo or maybe null." If we go with the latter then I still have no idea what is in this variable, and have to do a whole bunch of checking or array_filter()ing, otherwise I am doing this: $possibleNullValue->getInfo(); // BOOM! Even if there are use-cases for allowing them I would suggest that there are probably more use-cases for denying them.