Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112124 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25569 invoked from network); 26 Oct 2020 15:11:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Oct 2020 15:11:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3191018050A for ; Mon, 26 Oct 2020 07:29:30 -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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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:29:29 -0700 (PDT) Received: by mail-ot1-f52.google.com with SMTP id h62so8126973oth.9 for ; Mon, 26 Oct 2020 07:29:29 -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=sNyUeVQfpqdAnqZBCSl9U/GrnNsxZexbvwHAs4hH1p8=; b=jcf0NXIzvxovyyUu+o4DH7lIVgPkO9Sb0swkHvuCpvKVFspXRvs1S964vo2ZrsQ6z5 pBVLNV3lmuz5xSZZlTq50bcLbxCLWfmdRv6FjnsRqpbIBHjns5YOlWwL908FouFsX+Hk v0lb2W+0pETXVqOvbakEMZYaD83cg4Eq2okcswgrlKsoX5urw9U6VChp8+Ij1+4oc90j aQCIBiKFPSDcdW17X9ItlmkP/OH7i3eZt9qV/6GBN4qrU3iq/OP+eGhhHvFAmoOAiURc NGLfV2lJfZPvF8DZp5pE78QZBGmnpZgGBY+zfvXD5s82QfwkWuKr99RC4oPTnLa/AfTL Bg6Q== 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=sNyUeVQfpqdAnqZBCSl9U/GrnNsxZexbvwHAs4hH1p8=; b=QMc27etunhc16SvjjujYPC9cjoFWIvBitDUMoOaEIJv9yM7Pi/SsRT0vXCfwQ/6so/ KPkqFT/IomoupI5WF6kYMApZwGIMthQGDj11ZVTFcSRSLQvZakbjEBCApe7hjgiu8EG0 6RWMkyNGSzE+3uphyEeSwmY4Z1qTpaSXz0+glb9vds4oNh6GYUDp4BecmzBS/m8NTL8s 50DkzKo20yrJD9dMATYWbMsz5TABELdynL3pezH3SDNKZjc0QZia3qyc5nEVOhsCsdv8 UrsKe0Nke989GduGapIoRdc2IhJ2JjCfkrxnAR/4Z+4vTQ5yW9hJtZePcTyjq+JpiCQR TjdQ== X-Gm-Message-State: AOAM532IoQR/lCq8ZhhGZJbNVefTR6965i/nAYlQO4gb9eI/j/BorXA/ VzBcXDe6MfiKmPrBjgk30rN0dMJ9dDdmd8eKy80= X-Google-Smtp-Source: ABdhPJz8oRDFMiQPlTIR42vcqqQvnqnCOJLjput8VLN7TQOmFU6TtAPOcbGiv74JqGnH0hwgygFkYUiu6jZniOhPOnQ= X-Received: by 2002:a05:6830:22eb:: with SMTP id t11mr13552809otc.114.1603722569081; Mon, 26 Oct 2020 07:29:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 26 Oct 2020 11:29:16 -0300 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="0000000000000c672e05b293c24f" Subject: Re: [PHP-DEV] [RFC] Short-function syntax From: david.proweb@gmail.com (David Rodrigues) --0000000000000c672e05b293c24f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > The use of > instead of =3D> could if possible indicate the method being void > and reduce even more: I think that for void, it could just identify it and not return nothing automatically. function a(): int =3D> b(); // equivalents to function a(): int { return b(= ); } function x(): void =3D> y(); // equivalents to function x(): void { y(); } Atenciosamente, David Rodrigues Em seg., 26 de out. de 2020 =C3=A0s 11:23, Micha=C5=82 Marcin Brzuchalski < michal.brzuchalski@gmail.com> escreveu: > 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 th= at > 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 = void > 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 > napisa=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 > offer > > this RFC: > > > > https://wiki.php.net/rfc/short-functions > > > > Hopefully I made a decent enough case for it. It's entirely a > convenience > > 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 > > > > > --0000000000000c672e05b293c24f--