Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112122 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 22696 invoked from network); 26 Oct 2020 15:05:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Oct 2020 15:05:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 18F74180508 for ; Mon, 26 Oct 2020 07:23:26 -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,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-Virus: No X-Envelope-From: Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (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 ; Mon, 26 Oct 2020 07:23:25 -0700 (PDT) Received: by mail-il1-f171.google.com with SMTP id p10so8475010ile.3 for ; Mon, 26 Oct 2020 07:23:25 -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 :cc; bh=6CkQmeK9w/3lu2vj3D1dijvwjJQU+mcGcdaaXLehKVg=; b=kGj8+9pGra9dmGqifrYOISDA3ReGR7QSL4pZL37zB5HHUVnVbfaWtioaIlH6/2AVXI jpQrSH54/JAkdD9Jv0VhuuYtJCv7PPITOArwmlnlaqsuNGjs1/5vnx0WXUq3pzntn6kQ 6PBUNYnGmNR2bQ8ebiGvhZ7dy3FGrfUEk+/H5Q1O8X5M+pjkvYCalKnpMYCLDpOvKCfk vHbheo6PO7HAKOWIF+WcOcYwpCGbXpsRhZA/IY3J1wYehSjv/REIaThTSusqsj6Oa05x wthxPQbIgpMDxotSy4TeYzJ0UvVJAM3HjhIUhsKFi6Djx3PBxj+UmeMiqjT4tixkfedH 1U3g== 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:cc; bh=6CkQmeK9w/3lu2vj3D1dijvwjJQU+mcGcdaaXLehKVg=; b=gK6XqnZTfX9kv0uT2nlTMtizLZyOnbN7BugXmm0jhZKsNaeGSNtVTe8RJCDtDIWn4l J1jb6a+YmjNoQ84ZhGYO+H1VEd1M9v31+WDzZtn4DQfNFei0moAJV7Ikm4QFWDdklsH8 leau8FuZ80ZULyh1G/I59Hu+7bGwxTK/ZmswKYFdo0dvGgNX1Vq/f9VCaoE0UYo3R9Wd TWaGsCOQWQryeq+wwwWXeVXvrEi7yhn6rIKOoepk8UVBW1Sy2Whb/TEsELt/ORxin3pY 081e5kzXYhV15fNuWw8gYcB7OJqR/p9ywQczIGmY2zLpKEWbH7RwVggsP6XlKf739FRU GODw== X-Gm-Message-State: AOAM53037RDgGV+SgRhPDebMT4E7uSXEKo9Y1wJkWx4PgjoPZAWQSQ/G QMkAictdmdGbevgNOStLXJyr2ojOdnSk6Ik0NpdTpjULogPtkQ== X-Google-Smtp-Source: ABdhPJz3HNOobX0tsJf3G+Jz5+O87Ii5/QuiZrP35ykJSwRfNEKnVzagvdcUJO10gBZmJNtXMp+Ms6wPJNpjThXj6ho= X-Received: by 2002:a92:d806:: with SMTP id y6mr3812613ilm.264.1603722201349; Mon, 26 Oct 2020 07:23:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 26 Oct 2020 15:23:09 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="00000000000021432b05b293ac93" Subject: Re: [PHP-DEV] [RFC] Short-function syntax From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --00000000000021432b05b293ac93 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Larry, I'm wondering why we hadn't thought yet about reducing the need for $this in this syntax. Since arrow functions have an ability to capture variables defined in parent scope why not think of the same for class properties which will automatically reduce short methods verbosity. class X { public function __construct(private int $foo, private int $bar) {} public function getFoo(): int =3D> $foo; public function getBar(): int =3D> $bar; } And then going further why not removing =3D from arrow which indicated that there is no return value for void functions: class X { public function __construct(private int $foo, private int $bar) {} public function getFoo(): int =3D> $foo; public function setFoo(int $value): void > $foo =3D $value; public function getBar(): int =3D> $bar; public function setBar(int $value): void > $bar =3D $value; } The use of > instead of =3D> could if possible indicate the method being vo= id and reduce even more: class X { public function __construct(private int $foo, private int $bar) {} public function getFoo(): int =3D> $foo; public function setFoo(int $value) > $foo =3D $value; public function getBar(): int =3D> $bar; public function setBar(int $value) > $bar =3D $value; } Would it be possible? If not I think we should reanimate property accessors. Just dropping my 50 cents. Best regards, Micha=C5=82 Marcin Brzuchalski wt., 20 pa=C5=BA 2020 o 20:20 Larry Garfield napis= a=C5=82(a): > A while back, Nikita mentioned that it should now be easy to offer an > abbreviated syntax for functions that are just a single expression. I > decided to take a crack at it and it turns out he was right. I thus offe= r > this RFC: > > https://wiki.php.net/rfc/short-functions > > Hopefully I made a decent enough case for it. It's entirely a convenienc= e > factor, but I think for many OOP cases (getter methods and factored out > operations) and functional cases (where functions should generally be a > single expression conceptually) it does make the code nicer, more compact= , > and more readable. > > *dons flame retardant suit* > > -- > Larry Garfield > larry@garfieldtech.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > --00000000000021432b05b293ac93--