Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109120 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 11197 invoked from network); 18 Mar 2020 04:34:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Mar 2020 04:34:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A48551801FD for ; Tue, 17 Mar 2020 19:57:28 -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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, 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-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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, 17 Mar 2020 19:57:28 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id s13so25320054ljm.1 for ; Tue, 17 Mar 2020 19:57:28 -0700 (PDT) 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=dUmGqnmdoSpSuq0FWnLoAn7oY+X8phfulRtHINsgt0E=; b=ENNn3X6K4B/67XDQjAkPSfr1yuvbNKNSpIvaF5befh5uyKGE9oHu60teVxJRiVWIil MxQo1HpknYBOpM0/VE8JJEDW9ZDpVyehoxVqxceAKXXLiMxQinUvg2Xvpl85LnoYS542 N+vzu/8aPgdX4JxmqMuDiQe0bEDziZo1s2H8mo3w53wHVBBmD4E3lbeX6IMOxAs45MCq 207Vq3HqPhTJiuR8/8aQqpdzNWQNdi9N+r/W5fg5e8E2GYfTFn7W2+EqMH3/xX8qlUr/ zZlcjkEfoT8PVXan+09HWxsBdDYA5IHMzKbKPZWsTjPTDn9tnKnMMYb3RaUYCAJHmidj T/DA== X-Gm-Message-State: ANhLgQ08/cztUnXA/z5m8si/zD3FGA03eqrXgZa9z8UkwPo+GlH7BkiZ Tk1aaIWPpqdhYN/D3Hr0CEqN9rNevHew6Fwq/dc= X-Google-Smtp-Source: ADFU+vuAFwGiUQCQaKfwr4Mm7NiPiwy6H+pJ9aR+offeSIbQp3ocz3xntADUWXA01I+AH7zWqVRi/DyzxF+1McQj8LQ= X-Received: by 2002:a2e:b60d:: with SMTP id r13mr1003870ljn.185.1584500246645; Tue, 17 Mar 2020 19:57:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 17 Mar 2020 21:57:17 -0500 Message-ID: To: Rowan Tommins Cc: php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment From: jakob@givoni.dk (Jakob Givoni) On Tue, Mar 17, 2020 at 9:31 AM Rowan Tommins wrote: > Hm, I see, that does reduce the boilerplate somewhat, although it's still > split across two classes, and probably therefore two files, which is not > great. As an alternative to passive associative arrays, it's a small price to pay for splitting concerns and having a documented signature for the data structure. Named parameters is another alternative (unfortunately outside reach for now) that would work great for a limited number of arguments. COPA does not make named parameters obsolete, but works great for any number of arguments. > You're missing some code in your example, though, because you've documented > one of the options as optional, implying the others should be mandatory; in > which case you need something like this in the constructor: I've rewritten parts of the RFC and some examples substantially, and added your view of mandatory arguments in the "Open Issues" section. > It might be interesting to have the syntax run before the constructor > rather than after, or trigger some other magic method which could do > tidying and validation, so it could apply to more circumstances. Hmmm, in the Write Once Properties RFC they seem to believe that object construction is a "fuzzy" term and that lazy initialization is a feature. We can add better 'automagic' support for mandatory arguments, filtering and validation in incremental proposals, to avoid biting off more than we can chew, but we have to start somewhere.