Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108939 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29514 invoked from network); 10 Mar 2020 12:34:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Mar 2020 12:34:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D76B21804A7 for ; Tue, 10 Mar 2020 03:55:13 -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=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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 ; Tue, 10 Mar 2020 03:55:13 -0700 (PDT) Received: by mail-il1-f174.google.com with SMTP id a14so8437777ilk.6 for ; Tue, 10 Mar 2020 03:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=3t7GK2JY9t0RUsnrcqx3YxWH/Em6hvSQHDfaUc3Io+A=; b=WbxND5x3KEkavllkS5/4p8rqsC8nc5s8X7n0B+M1Efgv056/swYe9rJcZp39uFM40P Fz0/xTe7Tc62snceEDeXWPAHPvjTBqKypzLO6qRcfsIjbyG+mhNOEnj63EEaJ24YREIE peCK4C81IVBBsF4wGxL/KBh3Qk5qPa6nXy2kEF3RXeRIRJnP+361AFEd9s+ULMUzK+r0 7XMNLKnCZva1pYQpJeYR3LK+YQuWxT7NvGuNprWMJL3tXZBNmVosXsLDm7CwxCzopbJ0 7pkyP0eJIXLGkBw1Ws9XUUfkpkW8PFqoYpkPcL6BLdMvsNJqB2yNZWj3mgG5sCIqfoDZ FewQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=3t7GK2JY9t0RUsnrcqx3YxWH/Em6hvSQHDfaUc3Io+A=; b=aJH3ImNjkuiQOdy3zK2dDAcaz44pA0ylD85dmxvrGcCyig70WkvX9Dpav2CI+1TjZB xTCPWqXxTonZdIt4drzV3Rhe3F5s2TuSxSpBdAiFtki8vf9wYEwdYHkgiXx8h6Gc7h1U 6qnh/PnWqJZFqCW1gTcBiWH2LO3AAXMARkszCUqBGCaJcE7A/PguaY6i4Qs0LtrA91KG mJNlpEwGH+cU0E/88jhXZVl72rcDnoqpiOSD3LXIMIc/8kIfuLV054s0i7n4Z0rkccZx hVSFkHUYvOwg5mubx42MipMNgyLZL1XxdI6qzqymMyscBKZDJTdq0Lh6jhyrFHJqO2Uz CkOw== X-Gm-Message-State: ANhLgQ2R0Crh6RExq279dU5jWJzHJw6b/WsESea3wkedZH+5IjsWogHl lU2VCM6oke8NxtWydEQowsYu/kgG+kg7sA8qqPBJFrOo X-Google-Smtp-Source: ADFU+vsj95+wy6JZKx/tKFCZXPJ/nPcANFlN/nlGjIuR2nCHI5tWC9ez9pcfW47HmlPJXfLqM7V6KugY30c5V8muxkw= X-Received: by 2002:a92:d702:: with SMTP id m2mr18847150iln.149.1583837710926; Tue, 10 Mar 2020 03:55:10 -0700 (PDT) MIME-Version: 1.0 References: <2227A758-3035-4A43-974C-C4461A096DFB@newclarity.net> In-Reply-To: <2227A758-3035-4A43-974C-C4461A096DFB@newclarity.net> Date: Tue, 10 Mar 2020 10:54:59 +0000 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000002449c105a07df45b" Subject: Re: [PHP-DEV] [RFC] Attributes v2 From: rowan.collins@gmail.com (Rowan Tommins) --0000000000002449c105a07df45b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 10 Mar 2020 at 01:02, Mike Schinkel wrote: > > I find angle brackets extremely hard to read > You're definitely not alone in disliking the syntax, but I think it actually looks quite neat. It reminds me firstly of templating languages which use {{foo}} for placeholders and/or keywords, and secondly of French quote marks, =C2=ABguillemets=C2=BB. It looks ugly in e-mails using variabl= e-width fonts, but that's not we're going to be writing code in every day. > and fear =E2=80=94 have trained many newbies in programming =E2=80=94 tha= t it will cause > newbies who see PHP to think it is too complex for them to consider > learning. > I think the *concept* of attributes carries a much higher risk of that than any particular syntax. The same is true of things like generators, or traits, which use a more verbose syntax, but take a while to grasp. > You mention that the good symbols are taken, but why limit ourselves to > symbols? Why not use words like PHP uses for other parts of the language= ? > I guess the same question can be asked of any sigils and operators - why do we write "$foo->bar($a)" rather than "on foo call $bar with $a"? In the end, there's a trade-off: too many symbols become hard to remember, and hard to read close together; too many keywords become hard to read at a glance, and tedious to write. > Alternately, why not use this (which is probably the best option IMO)?: > > function foo() attributes > SingleArgument("Hello"), > Another\SingleArgument("World"), > \My\Attributes\FewArguments("foo", "bar") {} > This particular example leads to complications with how different keywords stack up; would the return statement come before the "attributes" keyword? if attributes were allowed on anonymous functions, would they come before or after the use () clause? The traditional placement above the declaration line keeps attributes out of the way of the main information about the function. It's also worth noting that all the other languages referenced in the RFC use punctuation, rather than keywords, for their equivalent functionality: C#: [Foo] Rust: #![Foo] or #[Foo] C++: [[Foo]] Java: @Foo ECMAScript (proposed): @Foo Go: `Foo` or "Foo" Doctrine et al: /** @Foo */ Hack: <> That doesn't mean PHP couldn't buck the trend and use a keyword instead, but we'd need a strong reason to do so. Regards, --=20 Rowan Tommins [IMSoP] --0000000000002449c105a07df45b--