Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110412 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36002 invoked from network); 7 Jun 2020 23:49:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jun 2020 23:49:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2591B1804C7 for ; Sun, 7 Jun 2020 15:32:46 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 7 Jun 2020 15:32:45 -0700 (PDT) Received: by mail-wm1-f49.google.com with SMTP id u13so13563013wml.1 for ; Sun, 07 Jun 2020 15:32:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=vldRHzDz+L4otN1ZJ0/KaDObs1iUkHXUpwO+uluLRNs=; b=iMhCtXFoAR2efTWlyB2rXcUv2v/BdWXKY/QvSt6+SJlGZ2VpMhSxqIw0VijZZV7USs 2AXv6VNKbGIn+Oe0rEIqguSucYP9Ee4orEsC6QdrMrGVPKjX7AG4m0G593kfLugyFQQI Lf5t0hncGmdweHOGXpJF78IsmigvwFLmlrKD3ugrvLdKDGFm3eMVmSwQP0a3AvUrIhV1 74YLfz6jW/tg2eTBf1z5rQ1HKD8SsSuTDx6R0/aSW69k4FUk6JtbC4J5liENox9OczOJ KxMjSZ8LOx3peNQ/4tKQofsFJYHWLu2uzhV09Rvc0RJrUj3tVJfKsVDu3cm7F6+MV78C cLPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=vldRHzDz+L4otN1ZJ0/KaDObs1iUkHXUpwO+uluLRNs=; b=F2MrL9Wi+bMIxu7GFh1BIpYXTaSU49pdLX8f9BmMmJfgWt4QVyohHB8caxTDfF52iQ dqJM4+OiZ6NM+Qt0YJu+Q+eTzrtyPYb9+reKDZ7MCIrELtE5lbw/xzTPK6E+Kapv5LnY /EPCnSkBuXwi0gqsdoDaSwqLALPPHY8vyBkrB2UIT1ri4cjU9zdAiBAcVv1b6JtR2mF8 iFS28Urpm6OKrrFDhH7SGXCN3rMEKF1ccjXqeVXzl1la4GwjgavNTA+5bevc75Rj+m1u +9jhEYVuYYBmzo723AXKoZ/Nr80UsPShNqaMaZE5BYPLgskgBp6XLnKDq1RK5J8ow/Qx 81jA== X-Gm-Message-State: AOAM5305TBGFjImhkxhtIw0yS3eSBV5Lew0dMVcTF0//G+mF17pXAJgk 5GXfMtJAgwcdgzY54E76s0ejSTqD X-Google-Smtp-Source: ABdhPJxZcR2BW3ji6g5IpGbwlgnE2rAU7JrwURS1gtckA9Qfil2VPW9+NhK67xqUkZSQhHjjpWcqhA== X-Received: by 2002:a05:600c:22c1:: with SMTP id 1mr14164523wmg.50.1591569161998; Sun, 07 Jun 2020 15:32:41 -0700 (PDT) Received: from [192.168.0.22] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id b132sm20582662wmh.3.2020.06.07.15.32.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Jun 2020 15:32:41 -0700 (PDT) To: internals References: Message-ID: <5ebecd58-9f39-72b9-369d-dbb60b80af36@gmail.com> Date: Sun, 7 Jun 2020 23:32:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Shorter attribute syntax From: rowan.collins@gmail.com (Rowan Tommins) On 07/06/2020 19:37, Theodore Brown wrote: >> If `<> )>>` means something like `new Foo( new Bar )`, then I >> can imagine it being useful for `<> )>>` to mean >> `new Foo( [new Bar, new Baz] )`. That would actually be more convenient than >> the double-at version, where you'd have to write `@@Foo( [@@Bar, @@Baz] )` >> or use a constructor with a `...$variadic` parameter. > In that example there are the same number of characters either way, so > it's not clear the nested `<<>>` approach would be more convenient. > And do you think it's a good idea to have an additional syntax for > creating arrays like that? It seems like it could get confusing. True, it doesn't make a huge amount of difference. My thinking was that passing a list of attributes as arguments to another would be quite a common case, and would add value to the special "nested attributes" syntax, which is otherwise just a weird spelling of "new" to work around implementation problems (if indeed it does actually work around them). >> Ultimately, it all comes down to judgement calls - is the >> double-angle-bracket syntax "too verbose", "too ugly" when nested, etc; >> and does the double-at syntax make it "better enough". > Yes, I agree that there's a judgment call to make. Out of curiosity, > given these shortcomings of the double-angle-bracket syntax, do you > think there are any objective reasons to prefer it over `@@` (other > than the theoretical BC break of code like `@@@really_suppress_me()`)? I'm not convinced there's any objective reasons to be found either way, but for the sake of "playing devil's advocate", here are a few that could be put forward: If grouped attributes are added, they're actually slightly less verbose than repeating a double-at prefix, once you have enough attributes in the set: Minimum spacing and punctuation requires n+3 chars vs 3n, so a saving even with 2 attributes: <>class Bob{} vs @@Foo @@Bar class Bob{} More realistic spacing is 2n+3 vs 3n, giving a saving only with 4 or more: <>class Bob{} vs @@Foo @@Bar @@Baz @@Quuxclass Bob{} Bracket-based syntaxes, particularly with grouping, are more clearly separated from the main code, particularly when used inline. For instance: $f = @@Something @@AnotherThing function(@@Special @@ReallyInt int $var) {}; vs $f = <> function(<> int $var) {}; Finally, typing up those examples, it occurs to me that @@ is quite a "heavy" symbol - it has a large proportion of black (or whatever colour) pixels - and inevitably a rather "fussy" one. I find it draws the eye more than the angle-brackets do, which feels unfortunate. Regards, -- Rowan Tommins (né Collins) [IMSoP]