Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114342 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 406 invoked from network); 10 May 2021 14:33:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 May 2021 14:33:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E4B911804E3 for ; Mon, 10 May 2021 07:41:10 -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-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (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, 10 May 2021 07:41:10 -0700 (PDT) Received: by mail-vs1-f43.google.com with SMTP id u188so1008822vsu.8 for ; Mon, 10 May 2021 07:41:10 -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=CTzC+5acUwxUoVbLV4KSJ8Pv+w2sSAYCSqEK0lcNnsM=; b=XYgpTTfS50xCZxG3ufQmXTQOoZdFcTdvUebee7sqCLRygJgUEemBbn8oymXLVnT7PG 3DStRHUL1Vs69fIONr1A9xypqr4pfhc9lzCFOFnxsIN2Ms1mQvO8naOt6zITvDrL9Sbv hIHVjEunaznV5Mzqyx/6XcQiUS59HW1q3sAVGtPdlTGxURj5k9dFPGIEEgNJNrY4RCeT SE5aKTCyjIazRecw4evdXIWu4o9FCrEV9cFCTWxpdmJBn+gkKIdWp3mR5PlnHrdGrH9d xOCJtSMyoh9rnH1pDdhP1G58Ml2oImx5W43tZdj/62w5I8v5bhUwi7wKiv9/8LVEXjb9 IsZQ== 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=CTzC+5acUwxUoVbLV4KSJ8Pv+w2sSAYCSqEK0lcNnsM=; b=RxvgDlbzOhW4ckmgWNPwzpFX5/WfaD4vGuS6MbRhqGfBTuOYvexNAcybha/bRYthx6 ymaqGAkTNGfo78Rb/KY1zNqhd+ZXIFzudeBaDoLnzs385JL/AxE8ptpTCUQSr8+oRomb +iDqTqpdv8EyRAA262eTAxSa7PUcAIyjcCYnsqF6tUMMNAMr2S+c8HQMY1xtOAouWPce X+fPunO7fWACbP6P4zdZTi7j6t2ABZT+DgZJvk1ix9OoZJFX4qwBWj5Exj58Cx06H9Mh AgoQEbDuQooO9Tq3N6iekYtJu2t94mX7oq3rt4hqJFHYk+A4nvddGjSlG4KusjC8e2WO aZNQ== X-Gm-Message-State: AOAM530ZfPoq9BKPntFXjnsiVBVkW2z0jFbduZLbnk1DUzyQnJCnxl3L XtZRntHeg9aPi96lUj+AbRPWSIRNhd0Nc6Nteas= X-Google-Smtp-Source: ABdhPJxnQosvV7dL9FNsJ8rdWCBhGk5rT4vgQ3DG3zgiCArumdliBrdCmzKnD9L9Mft6tyBOqI3Ch/Jw2rntWDOgZjw= X-Received: by 2002:a67:c897:: with SMTP id v23mr19422952vsk.21.1620657667911; Mon, 10 May 2021 07:41:07 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> In-Reply-To: Date: Mon, 10 May 2021 10:40:56 -0400 Message-ID: To: Guilliam Xavier Cc: =?UTF-8?Q?Mat=C4=ABss_Treinis?= , PHP internals Content-Type: multipart/alternative; boundary="00000000000099342805c1fac468" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: chasepeeler@gmail.com (Chase Peeler) --00000000000099342805c1fac468 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 10, 2021 at 6:31 AM Guilliam Xavier wrote: > On Mon, May 10, 2021 at 10:29 AM Mat=C4=ABss Treinis > wrote: > > > Hi everyone, > > > > Since constructor property promotion is now implemented, and it looks > > like it could become a widely used feature, I am proposing a small, > > cosmetic change in syntax for constructors in concrete classes to do > > away with empty constructor body. > > > > Here's an example of how this would work: > > > > > namespace App; > > > > class Foo { > > public function __construct( > > private Bar $bar, > > private Baz $baz > > ); > > } > > > > Some notes to this: > > > > - Since this is similar to already existing syntax for body-less > > methods, parser should not be affected that much. I hope. I really have > > no idea. > > - Syntax would be optional - meaning, you can as well continue using > > empty body, just that in this case the body would be implied empty. > > > > Thoughts? > > Regards, > > - Mat=C4=ABss > > > > > Hi, > > To me `;` means not "empty body" (that's `{}`) but really "no definition, > only declaration" (or "no body, only signature", and also "no code > executed"), i.e. an *abstract* method (either explicitly declared so in a > class, or implicitly in an interface). > > Granted, property promotion is already special (cannot be used in an > abstract constructor), but it can also be mixed with non-promoted > parameters and body, so I feat that your proposed alternative syntax woul= d > bring more confusion than convenience :s > > Regards, > > -- > Guilliam Xavier > I'm ambivalent about this proposal, but figured I'd throw out one advantage to ; over {}. In my opinion, ending with a semicolon is a very clear way of saying there is no body to the method, while having {} could indicate that implementation of the body was intended but never actually done. I know that when I'm writing new classes I often will set up the method signature but leave the method body empty while I finish the code that utilizes that method. I don't know if that is justification for the proposal, but it is one reason why ; might be preferred over {}. --=20 Chase Peeler chasepeeler@gmail.com --00000000000099342805c1fac468--