Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117957 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 61091 invoked from network); 15 Jun 2022 22:12:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jun 2022 22:12:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DC8DF180384 for ; Wed, 15 Jun 2022 16:59:55 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 15 Jun 2022 16:59:55 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C13B45C020F for ; Wed, 15 Jun 2022 19:59:54 -0400 (EDT) Received: from imap52 ([10.202.2.102]) by compute1.internal (MEProxy); Wed, 15 Jun 2022 19:59:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1655337594; x= 1655423994; bh=SRbTrCgNZ1YnyKsmTtM0i2xFjnqmbWEQuPGA1RDBz34=; b=G ugNrdfS/iGVDwD7cRckBDMU0tG+J0xW1RK0YCGGTOyTin5Uj9xHmD3ZpM+QyQTwi 6V/fhqJzUP4nL1TIQkEGeIa/S/CicI9QoWarTE1YwGQcP2p8zPJDR5+FffVTUKkj wbdhSe/fAr+alC/PyYSwlqAUOsPgmGn7Gr2q+9DG5IA6WIKxAa7fIO6tC0Gs41Fp 6xvbX6cupg9rtoCz6JbAtTGbN84sXGukpR48VI38bvP45xIEYyXZ+EuV0iU5JsLR orfzAvAi/VYqMpuW4HDL0ibqhZaNcNBVU7vD/JVnjk3Rs14PoxciEml8S1AFiuS1 CouqYIsLfSJwT0sFIpKyQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1655337594; x=1655423994; bh=SRbTrCgNZ1YnyKsmTtM0i2xFjnqm bWEQuPGA1RDBz34=; b=U0W/ujkNuVbE1si96BQPfU+cnKsqmiMoCqzL7hLSG4pd RWIC/ryH3wXQsqNB/Vy+zLz9K87ORs/5en6dVq5AGus6XeUjcU45g/gq0sAipJbh FzJHSOYZJP1uJspRBv3gA/dmju8keEjkUHIV1U3YE6bEMSAzbxjMGRbWknMaGdKQ 4/i3pJAq0mSORIc1FCC8v9kARQL9C/jcnOWoXY8BU+OY5oYTikKcPRHdBlymuozw CKAgxDl+8i/02ZJQSVwImKg1EpxWwY/18+HVBFL6yosKLl+RPi9+xuUQ6AwAgQGQ d/KM1LZLl8cL65GULbsEfCu+d1Ogva+6xbdPhAEi7Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvvddgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpeeglefgkeduiedvvdetffeujefftdfhjeeiveehgfff keduveektddvledvvdfffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7B9D0C6008B; Wed, 15 Jun 2022 19:59:54 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-712-gb9e94258b0-fm-20220610.001-gb9e94258 Mime-Version: 1.0 Message-ID: <4ba5cd49-2efa-4007-9298-d6a66363d3b0@www.fastmail.com> In-Reply-To: References: <2b35605f-8da8-46b1-aec3-00bd1bfe47fd@www.fastmail.com> <2347345.PIDvDuAF1L@arnaud-t490> <11078866.5MRjnR8RnV@arnaud-t490> Date: Wed, 15 Jun 2022 18:59:33 -0500 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Short Closures 2, aka auto-capture take 3 From: larry@garfieldtech.com ("Larry Garfield") On Wed, Jun 15, 2022, at 7:05 AM, Guilliam Xavier wrote: >> > > Because variables are captured by-value, Short Closures can not have >> > > unintended side effects. >> > >> > Those statements are true for scalar values. They are not true for objects: >> >> This is shown in the "No unintended side-effects" section of the RFC. > > I'm confused by the last example: > > $fn2 = function () use (&$a) { /* code with $a AND $b */ } > > Isn't that missing a ", $b" in the `use`? > > And like others, I also find that allowing mixing explicit *by-value* > capture with auto-capture is not really needed and even confusing; if > you "expect that explicitly capturing by value will be rare in > practice" you might as well forbid it? Arnaud and I discussed it, and we're going to drop the mix-autocapture-and-manual functionality. I was tepid on it to begin with, and it can be confusing. RFC will be updated soon. > By the way, what about *arrow* functions? e.g. > > $fn = fn () use (&$ref) => $ref = $val1 + $val2; // assigns and returns > > Would that be allowed? Is it really *desirable*? I don't think it's really desireable. By-ref closure is unusual, probably even less so in one line closures (though I've not checked that specifically), references are usually a bad idea anyway, and in those unusual cases the long-form is still there if you want to control everything. --Larry Garfield