Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108201 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53299 invoked from network); 20 Jan 2020 03:34:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Jan 2020 03:34:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6F3DE1804F4 for ; Sun, 19 Jan 2020 17:43:00 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS701 96.241.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from nebula.zort.net (unknown [96.241.205.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 19 Jan 2020 17:42:59 -0800 (PST) Received: from [10.0.1.2] (pulsar.zort.net [96.241.205.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nebula.zort.net (Postfix) with ESMTPSA id A143E200B8106; Sun, 19 Jan 2020 20:42:58 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 nebula.zort.net A143E200B8106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zort.net; s=zort; t=1579484578; bh=RQ57gsV4+IW2leSK14oDLZCXM5ZnE4qOvO+sqz6yyWY=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=HZ4d3BIJ6XNw/uCQxMKp5oE0orm/CS7aBSM+bqaFrnUbjWhIylCIvzx+R7EDfVi8M 2fQCBUToymtyJd/HCTQgN//XAk9tgrEcZ9fg7soYvp7Q3UhwbnA1n6IVTS/2eWmUVu 8J9BgTbV/3PNa7YtYMvXgAD6FLIdb6WXMNkMvBR8= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) In-Reply-To: <5DC86728-1BBF-4DCA-8A6B-9B0B190DB99D@newclarity.net> Date: Sun, 19 Jan 2020 20:42:58 -0500 Cc: Nikita Popov , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <191B2F45-C9F2-49EB-A19B-9C3D8A705AD6@zort.net> References: <5DC86728-1BBF-4DCA-8A6B-9B0B190DB99D@newclarity.net> To: Mike Schinkel X-Mailer: Apple Mail (2.3608.40.2.2.4) Subject: Re: [PHP-DEV] Typed array properties V2 From: jbafford@zort.net (John Bafford) > On Jan 19, 2020, at 19:53, Mike Schinkel wrote: >=20 > P.S. There was also the mention by Levi Morrison that the type[] = syntax was a poor one because of ambiguity between (?int)[] or ?(int[]). = I would argue that the latter would likely occur orders of magnitude = more often than the former, so I would argue that ?int[] should = interpret as ?(int[]), and if they want (?int)[] then the developer = should use parentheses. As a thought, perhaps the syntax '[Type]' for an array of Type. That = way, you could write ?[int], or [?int], or even ?[?int] and there would = be no ambiguity, and no need for parentheses since the array brackets = would serve that purpose. If we also wanted to allow typing array keys, this syntax could be = extended to [string : Type] and [int: Type], and it would continue to = remain unambiguous, even with nested arrays, and with using a more = similar syntax than the docblock syntax array. (It might = also be reasonable to support both variants as aliases of each other.) Both of these are the syntax Swift uses for arrays and dictionaries, so = the syntax has precedence from another language. Swift also supports = both syntaxes as described above ([KeyType : ValueType] is exactly the = same as Dictionary), but the shorter bracket syntax = is preferred for readability. -John