Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109421 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70492 invoked from network); 29 Mar 2020 22:32:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Mar 2020 22:32:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A45E21804C2 for ; Sun, 29 Mar 2020 13:57:54 -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, 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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.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 ; Sun, 29 Mar 2020 13:57:53 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id x200so5210934lff.0 for ; Sun, 29 Mar 2020 13:57:53 -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=PQYU9oFM5DLv/ZEwWzkjT65Mr/ZLxdIkDKaJ69FjNFQ=; b=dAYz8I846hJkIoOJBrqaUaJ//0pZbA2AtlMRspGM3xlmzXxtLXfXTXdP6ZxXssBJSW dpYVw233xl9EFKTHCMQST/KJfYgzkxqMS6u4kL6cmdX5Aqbz9Kx/akuDdAn16Vwh4tEJ etKlo6UJwNmq0jk5I8ibGoagVAZfjgr1aDUXI4FeBFy/hXroxqN3zdZzm9DeeqyJZjuJ ualSSkOjLxC6X+nssDpMxWHXaYmKBf5VbWmY/0lulNiuGen1PGhKoq8RE4VwhJuyFqj4 ImAKAjoOxyPl7LqSE4XRHXI2c3tcHeHDnbGDC9ZJUy9iR8lE3Jxt1VJmWesvD1Y3SrX8 Rh9Q== X-Gm-Message-State: AGi0PuaksBOKionOPXevgNtxrXxGUwgtB/47AMr72rpH2wG+/c9Tqp3x Dh64m1+7kyIXiePoq0Sn9NiDXU97gxcNpoLq1Gs= X-Google-Smtp-Source: APiQypIlAXKRlOZYYFKiS/013iqSrfke74pygS8vKDGc7b7GbUSb/WH71EbViEBdoIMC1VJ5+u8HDGL7jNZaQY3zktw= X-Received: by 2002:a19:4a96:: with SMTP id x144mr3093460lfa.76.1585515469411; Sun, 29 Mar 2020 13:57:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 29 Mar 2020 15:57:38 -0500 Message-ID: To: Rowan Tommins Cc: php internals Content-Type: multipart/alternative; boundary="0000000000005717fc05a20496c2" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Compact Object Property Assignment From: jakob@givoni.dk (Jakob Givoni) --0000000000005717fc05a20496c2 Content-Type: text/plain; charset="UTF-8" Hi Rowan, On Sun, Mar 29, 2020 at 10:00 AM Rowan Tommins wrote: > > myObj.with { > foo = 10 > bar = foo + 20 > } > I really like the suggested "with" syntax, - in fact I had contemplated something like that along the way. The slight "problem", I think, is that, as you mention, adding a fully fledged "with" syntax would imply that you could do a lot more than simply assigning values to properties. And while I agree that that would be cool, it feels like overkill for the actual problem COPA is trying to solve. Do you think a narrow version of "with" syntax could be incorporated into COPA without causing frustration? Or would it be wise to give it its own RFC? I haven't researched if there have already been RFCs proposing something along the lines of "with", and as such I have no idea if it has already been discussed and found problematic. > I'm not sure whether I like this idea or not, but I thought I'd share > it, because I think COPA as currently proposed is too narrow a use case > to deserve a special syntax. > I understand and fully agree that COPA is narrow, but I don't really understand why that's a problem - I proposed it exactly because I felt that its simplicity is its force. Low hanging fruit is usually something I would encourage to go after. I believe it's a trivial implementation that can help in uncountable situations where you just need to assign values to a predefined data structure in a single expression. I'd really like to hear the arguments against such a cost-benefit calculation. Cheers, Jakob --0000000000005717fc05a20496c2--