Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71192 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49821 invoked from network); 16 Jan 2014 20:14:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jan 2014 20:14:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.128.46 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.128.46 mail-qe0-f46.google.com Received: from [209.85.128.46] ([209.85.128.46:60545] helo=mail-qe0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DE/84-21406-39D38D25 for ; Thu, 16 Jan 2014 15:14:13 -0500 Received: by mail-qe0-f46.google.com with SMTP id 8so3065532qea.33 for ; Thu, 16 Jan 2014 12:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:date:message-id:subject:from:to:content-type; bh=+MFK+CnU5JDt42UZ/odQvKNC0VPTVwGQ+1t/pvVqAEQ=; b=o66L0aROdo9+0sb2+CDZl2u53WM6QTh48j1c2VLFjQ4XAZZKnN+3ujJnrhVgJMuH9F 3H6BLYaWTxbFPx5N6MLaC56kIAuC7Kl9gObfwFFWInNwb2eVVqnCSHVCgwvB0EI+a/RQ 6P9uwpM+TFS7nL+9qqlyppEB3tC8g7oOnN8eY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=+MFK+CnU5JDt42UZ/odQvKNC0VPTVwGQ+1t/pvVqAEQ=; b=eGqBhlVixv6tdfYthCijlng+FdZPWtitze4tQxWv9wqKXpMmgrGHpV9C15C+d4t2OK Y/wLBOea5vALj8HpJCbXwbgh1H0zdbBJGSDQ0+31K/n3vbKMcOGdf3rhXNrI68saj8F7 dtPWx01IXds3FVzDaYKTlb2PPQajCSu0Ae7/VLFAIqPgS1MX8OBcIyMft3owX+CvWR/D 4Dy4GiRHJKAWX5AxYTW2N8TYLOd2EzhM3wLh3+b3nXdOsmxgjDDVnaghjQGRtvtrXclt J9dHFG0HUO7wrNGYmaaaWrtfDBMC1AIR1ujw53x7tj6RAkkeaWTgiM1C4dnl+LhJzpad ZEBg== X-Gm-Message-State: ALoCoQkLhs+Ztoi7WVFj4YWqmeXbr+BUV+oTSNADQjruL8iKQfo40DNPHhl9+LupN3Rg5wCrM1ZP MIME-Version: 1.0 X-Received: by 10.224.115.19 with SMTP id g19mr19226496qaq.95.1389903248699; Thu, 16 Jan 2014 12:14:08 -0800 (PST) Received: by 10.96.182.98 with HTTP; Thu, 16 Jan 2014 12:14:08 -0800 (PST) Date: Thu, 16 Jan 2014 22:14:08 +0200 Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7bdc86a26947cc04f01c1114 Subject: RE: [PHP-DEV] Introducing "Array Of" RFC From: narf@devilix.net (Andrey Andreev) --047d7bdc86a26947cc04f01c1114 Content-Type: text/plain; charset=UTF-8 Am I the only one who finds both proposed syntaxes somewhat confusing? The originally proposed 'Bar[]' simply looks strange. HHVM's introduces even more "special characters" (<, >, ?) to parse, looks a bit like a regular expression and it was even already mentioned that it's "imported" from C++ ... PHP is not C++, and why should it be? 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 It's easily readable and everybody should be able to recognize what this thing does even without prior knowledge. Hell, why not Array[Foo|Bar|stdClass|whocares] ? 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. Cheers. Andrey. --047d7bdc86a26947cc04f01c1114--