Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71194 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53708 invoked from network); 16 Jan 2014 20:28:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2014 20:28:09 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.216.193 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.216.193 mail-qc0-f193.google.com Received: from [209.85.216.193] ([209.85.216.193:43203] helo=mail-qc0-f193.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/65-21406-8D048D25 for ; Thu, 16 Jan 2014 15:28:08 -0500 Received: by mail-qc0-f193.google.com with SMTP id m20so763449qcx.4 for ; Thu, 16 Jan 2014 12:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=TOE/IwMwmqcoW3CzzccPjAa5hqx6n1T9MsN1Ao82aQQ=; b=CmeFgDWL2FKRBOSrFPLEwYupycV5om/qqXgl7JKOk3t0L53w8WZtXwXnnUYF/UpZa7 H+gkMen4wnZdfkN/wbDpvrWrNCD+w/rCPz9BjedrCS2uzQMk2sKaIXT3p7sBy0wweGRD zl1ITImQdTkSdf//YVlUsmN2Vatd2gzqhGFJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=TOE/IwMwmqcoW3CzzccPjAa5hqx6n1T9MsN1Ao82aQQ=; b=OYxAX/4pZsW4KB2+zM8W8/OSvnh84bgYAbcJad2b+mokx/2wgW78NWPXdYyyHTSX3n PLtbBJYfLAimavFC0EsZSIS3+i8WkymxlJG5eeb70TEP07kc+Lt19P+z0GkdoRyUJs1f lwQFArofcMwWBK8hYusH/blmMpuL3zjOOPs3U0zB8IuHZGkaUDnjyyEvEDIGHfyHJgTU EP+Pzs+cUu4VUjaT4vAZt9QRkDhWII73TFM7ozSEBWLO0hlZVB9NBO2+S+5u4a6nxubJ YyjLpZUK4Ti1ob5EWgUDttUi/pIW2lARn5NqNsHUDE+t6T1fooexs4tbw22g7OPR+QgE lhsA== X-Gm-Message-State: ALoCoQmormiRIdhRpGO8OqEjAT8WGK2XIo3Z6cbculXiM9MbU9xWPz6TQ7sI5AkjBwi+A8r04pPu MIME-Version: 1.0 X-Received: by 10.140.95.139 with SMTP id i11mr11678480qge.1.1389904085659; Thu, 16 Jan 2014 12:28:05 -0800 (PST) Received: by 10.96.182.98 with HTTP; Thu, 16 Jan 2014 12:28:05 -0800 (PST) In-Reply-To: <52D83F13.3000702@ajf.me> References: <52D83F13.3000702@ajf.me> Date: Thu, 16 Jan 2014 22:28:05 +0200 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c1467e4cd56504f01c4347 Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: narf@devilix.net (Andrey Andreev) --001a11c1467e4cd56504f01c4347 Content-Type: text/plain; charset=UTF-8 Okay, so for contents and [Bar] for keys, although AFAIK you can't use objects as array keys. These were all random thoughts, I haven't though about it all in depth. Still, I believe it's more intuitive than both previous proposals. On Thu, Jan 16, 2014 at 10:20 PM, Andrea Faulds wrote: > > > On 16/01/14 20:14, Andrey Andreev wrote: > >> Am I the only one who finds both proposed syntaxes somewhat confusing? >> >> The originally proposed 'Bar[]' simply looks strange. >> > > It is, however, familiar to C, C++, C# and Java users. > > > So, how about this: >> >> Array[Bar] $a - $a is array containing only instances of Bar >> Array[Bar|null] $a - $a is array containing Bar instances or nulls >> Array[Bar] $a = null - $a is either null or array containing only >> instances of Bar >> Array[Bar|null] $a = null - above, but the array can contain nulls >> > > That doesn't make much sense as a syntax, IMO. It looks like "Bar" is the > index of the Array here. Surely it could use angle brackets, which would be > familiar to people who've dealt with generics (C++, C#, Java users): > > Array $a > > > It's easily readable and everybody should be able to recognize what this >> thing does even without prior knowledge. >> > > It's not clear to me at all at first glance. Is that a Bar-indexed array? > > > Or even (at a later stage): >> >> Array[]["key1", "key2"] >> >> ... which would hint for a numeric index array containing associative >> arrays that in turn must have the defined keys. This is indeed a bit >> crazy, >> but possible to add in the future without BC breaks. You could even shove >> scalar typehints in there as soon as they are implemented. >> > > ...that's even less intuitive to me. > -- > Andrea Faulds > http://ajf.me/ > --001a11c1467e4cd56504f01c4347--