Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109473 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17453 invoked from network); 31 Mar 2020 03:32:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Mar 2020 03:32:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8336C1804C3 for ; Mon, 30 Mar 2020 18:58:45 -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.3 required=5.0 tests=BAYES_50, 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-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 ; Mon, 30 Mar 2020 18:58:45 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id u15so6848246lfi.3 for ; Mon, 30 Mar 2020 18:58:44 -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=CxrHu7QCU6WjLj+bubBrdhYZdWwXukIVc/Gw5PLXhEs=; b=rMyKM2YZWhEjdd6zarwN/f5nJ5d8M75vLjiLqoWIhu6ye965KHWNuhWHfVPdsMFOUB NlNxSYvP4D843RGxOU6FzXScYV1NXf6jmyDO4K1noy62v6qc3t+CbY9uHZFufCM1Lbj3 cFHELWi94Geh05Uj7l/V8jcvljuGrVq/FZewJuwH3cFWrEyZPM0I2raWVdn0Ou3MSX+v 5VtrJBWUm/T2ojLFjEZ3lLhItARBIAr4xAABCorzQa0QOcv+LfSLQt+dH5u687Pwb31p lqAGgydBmU+mzp3tF5ce/B27Qcf8G2bGQUwyaTQNLmDG61MFXVFhnQsDmbT4LrZ0iK6Y Bhjg== X-Gm-Message-State: AGi0PuY/yc0uu/MxcbGIe4iBpUBmXUCCW/NUFfqHk26YCfY0NiQgLNxd LvSNfCh6etksm/VXO9zyjbWjSQnVJZ30tQVbDdB51Q== X-Google-Smtp-Source: APiQypJ+UmN3iT/1MArHRmXUfmir0rJNdWzDuZ5AQoYugVkNirRHfflDUYrrFyYgo4kIlv3tmxtbEhj1QvIZawo14V4= X-Received: by 2002:ac2:414f:: with SMTP id c15mr4940590lfi.2.1585619923249; Mon, 30 Mar 2020 18:58:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 30 Mar 2020 20:58:31 -0500 Message-ID: To: Larry Garfield 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) Hi Larry! I have a lot of respect for the vision you're working on. Great advances sometimes come out of great visions. But let's not forget that so far it's only a vision and not all visions come to fruition. We don't know - at the moment it's anybody's guess. At this point I hardly expect you to change your mind, and it's not that you don't have all the right in the world to an opinion, but it seems to me sometimes it's easy to confuse opinion with fact. Hence, for the sake of my own sanity I will reply to some of your comments. If you feel we're going around in circles, feel free to ignore my replies. For sure, no need to double down on our disagreements. On Sun, Mar 29, 2020 at 4:59 PM Larry Garfield wrote: > > I went into this in my earlier Object Ergonomics post, but in short, it's quite possible for a solution to be *too* narrow. > It becomes useful in too small a subset of cases to justify its added conceptual weight. And what exactly is the added conceptual weight of COPA? As I've stated time and time again, COPA doesn't introduce any new concepts or complexities. If you disagree with that, I'd really like to hear exactly what those new concepts or complexities amount to in your eyes. > (and contrary to the view of some, "if you don't like it don't use it" is just not a thing when you're working in OSS, > because someone is going to use it and you'll inherit that code). Yeah, God forbid such madness! :-D > A narrow solution can also inadvertently serve to make something too easy that should be done rarely. > [...] > Or it would nudge users toward making more properties public so that they can use the shorter COPA, > but in the absence of a readonly keyword, asymmetric visibility, property accessor, or something along those > lines that is a net loss as it means more properties become public when they really shouldn't be. Hmmm, record-like data structures (structs?) - devils work in disguise, for sure... :-D If I were being arrogant I'd say that maybe allowing a trailing comma in parameter lists will nudge users towards making methods take more parameters than they should. But I think it's prudent to be modest in such judgements. > In this case, the problem with COPA as proposed is that it only works for public properties that are assigned literally. That is, in my experience, a very rare case. You see, here's the funny thing: It's rare because it's a hassle! *MY* experience (I do have some 20 years' worth of such...) is that people tend to use associative arrays instead for data records and the like. COPA aims to change that. And it's not true that the values have to be assigned literally - the assignment can invoke a magic method which can validate and modify a value and store it privately. I'm not saying that is good or bad, just that it's possible and that fact should not be misrepresented. > Most objects want and need to have private or protected properties for a large variety of reasons, which would make COPA useless. Ooops, careful with such an overstatement, buddy! I don't want to enter into this debate here, just point out that this generalisation is overreaching. Again, some modesty would suit the debate better. Truth before emotions also. > IMO, the combination of constructor promotion and named parameters would have a much better ROI than a dedicated syntax, > it would not suffer from the public properties problem, it would still allow for constructor parameters that are not a 1:1 map to properties, > but it would still serve to greatly reduce the amount of typing needed. That is, that approach offers more functionality for roughly the > same or less additional syntax. The proposed syntaxes for those features are much more complex than COPA's - I hope I'm not misrepresenting it when I say that it currently involves 2 new ways to write a constructor, moving declaration of properties inside a method signature and a whole new annotation/attribute paradigm to try to make sense of it all. And we're nowhere near consensus on any of it. The revived constructor promotion syntax cannot replace COPA without named parameters - and named parameters has not made any significant progress since 2013, unfortunately. I would love to see some form of named parameters, but I'm not holding my breath for it. > In short, the cost-benefit calculation says this is useful in too narrow a case, and has the potential to encourage bad design in the name of typing less. > Other alternatives address that problem space better. To list the facts: - Is COPA narrow? Yes - Is COPA useless? No - Will COPA encourage bad design and be overused? Opinion! - Will COPA encourage struct-like objects over anonymous array? Yes - Will COPA pollute the symbol/syntax space? Very little - Does COPA have any implications for future language evolution? None that have been shown so far - Is COPA trivial to implement? Yes Larry, keep up the great work with the Object Ergonomics. I'll follow it closely and contribute when I can. I will move forward with the vote soon. Based on the latest feedback I'd be surprised if it got even a single yes-vote, but I want to have this experience under my belt as well. I respect the vote. I will learn from it in any case. I only wish the vote isn't skewed by opinionated misrepresentation of COPA. Thanks for reading and code responsibly! Jakob