Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114415 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1890 invoked from network); 11 May 2021 16:52:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 16:52:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 766F4180211 for ; Tue, 11 May 2021 10:00:06 -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-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.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 ; Tue, 11 May 2021 10:00:06 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id i9so23105404lfe.13 for ; Tue, 11 May 2021 10:00:06 -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=PWeiPT5BtCgh7W426dCM145rAw/ViINM0+e9lZvLCBc=; b=m9BW3rMevFUzkwE8FqgwGVyL8/MqLsjlGs5SqmD3RpLVEHlIKl7HhejZ4KcOpXTfNb NZ+3UuV+wiamDge0+bSnOg1TIjWWhOLO0VAPFV6dzDe+eydEfkqve8r6bSiczVMAnhQX r1kNJGEQmkeZEGqwvKM+QQ67bmhxjUdpX1U54V1qxIo51k/iUJYh5ImAVresaclrVvbQ 2UUSfX3mED65VssKI8HJkDCt7jakVL+Rg4gO8vxZgsISbKuHMmB4OT7+W5Am+5oYZce/ DjSQyuDURgQTn/JDQgsd3dboWrXOyYTahJod3E0yDJfpwvNKAAbhJ0JoBl/0FrK1McBf XBmw== 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=PWeiPT5BtCgh7W426dCM145rAw/ViINM0+e9lZvLCBc=; b=RkkiPRup//EkX3916aNOlEgJH+Iwmrd6jFj5T0lLE6kDv1rdeutZQ3qdoR52XxSVQR 3zBAg4DVq1W4lx+mrnE54Nwruawl/T0ohj7VjKfLQp1cr0aS3iKEn/dN4rb+Y0XiOG7q nOHB3EwC2v87W/i2fN9mnfr0nT97HeykCESg/aSpfKH1EAAM2zwiqHn7UuIHCYNnKZIH j8GUynIZqbBny8ivc3rCigPl6ZoOEUFR3t/bvCSPRwp+T7Del9g5Y95KUDuZj6Ez/Qkq nn8+Bu1PAXjJ9A6sl9/YnLLCDFIiiMphVEXCsVIWo/YDEP0UmPesIvxXUvdNMXDNJlNn I65A== X-Gm-Message-State: AOAM531xfGJH0Yhz/7UpDYsJ4LwP4r8UllPW8u1ayGvnHtE5KmuOEqIO tybkeRDve0AaH4fKTMopleiJ6TSqhCgCpsOIkhI= X-Google-Smtp-Source: ABdhPJwmkOXo9PpQAEJINCs6xuFPvzRoNmI3r9GZqllumHhrbV0cDRx7LJnsw/fl4cb9rQ/oH7p9KnZApdZGRNYCGFg= X-Received: by 2002:ac2:5e25:: with SMTP id o5mr10723637lfg.638.1620752404805; Tue, 11 May 2021 10:00:04 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> <20210511163711.122e46c1@mcmic-probook.opensides.be> In-Reply-To: Date: Tue, 11 May 2021 18:59:47 +0200 Message-ID: To: Matt Fonda Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000005b7ac505c210d3a1" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: nikita.ppv@gmail.com (Nikita Popov) --0000000000005b7ac505c210d3a1 Content-Type: text/plain; charset="UTF-8" On Tue, May 11, 2021 at 6:56 PM Matt Fonda wrote: > On Tue, May 11, 2021 at 7:45 AM Nikita Popov wrote: > >> My thought here is that a constructor with (only) promoted properties is >> hardly a constructor at all -- it's more like a special syntax for >> declaring properties that happens to re-use the constructor notation, >> because that allows it generalize in certain ways. It could have been >> implemented with some other syntax that didn't explicitly mention >> constructors at all, such as class Point($x, $y, $z) {} or something. >> > > Agreed. I've personally been a little hesitant to start using CPP because > of this. Declare constructor parameters AND declare properties AND > magically provide a constructor implementation that sets their values. It > looks like a constructor, but it's actually a little different. For me, > this proposal would really help clear that up. > > When I see a method with an empty body, I think "this method does have an > implementation, and that implementation does exactly nothing." In the case > of CPP, this isn't true. The method appears to do exactly nothing, but in > fact it has an automatically defined implementation that sets the > properties to the given values. > > When I see a semi-colon-terminated method, I think "this method has no > implementation *here*; one will be provided from somewhere else." This is > the case in abstract classes and interfaces--the subclass provides the > implementation. And it's the case in CPP too--an implementation that sets > the properties to the given values is automatically provided. For this > reason, I don't see it as inconsistent. The semi-colon means someone else > will provide an implementation, and CPP does just that. > After you put it into these terms, this reminds me a lot of https://wiki.php.net/rfc/property_accessors#implicit_implementation. For accessors there's very much a difference between public $prop { get; } // auto-generated get and public $prop { get {} } // explicit get that doesn't do anything Making "allow replacing {} with ;" as a general feature would certainly pose a problem for this choice of syntax (which is inspired by C#). Regards, Nikita --0000000000005b7ac505c210d3a1--