Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112261 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68524 invoked from network); 20 Nov 2020 15:50:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Nov 2020 15:50:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D79A2180531 for ; Fri, 20 Nov 2020 07:14:54 -0800 (PST) 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, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 ; Fri, 20 Nov 2020 07:14:54 -0800 (PST) Received: by mail-lj1-f180.google.com with SMTP id h23so10365855ljg.13 for ; Fri, 20 Nov 2020 07:14:54 -0800 (PST) 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=8UqHRWz5q7ezm4whJQ9dP3CqVWj6hAi2hz9iOSS9WXU=; b=Ej7nZ5Ox/J/mGeAtXpAVNFVYDs3obudXnrSrZ9xfYygLZQbIHAIQZGmoOftybljjTR jVWj34l84bJ0VCzGAFocuppN6t3P6Y2VOUvEQbwX2veYhD46U9OqJI9b7VIIS7F1kw9w b+Vn5GCx6jKUWdRikZzub6WaDiiwev7Ly2FT8cpetXKN29pRLSS73+l2wn7W1BpErxnP pTy1l4LwEl5u4MtEmekPYDvX2D8QHykcLqToghNn9O4/fHG+7L60Im4q0lpZ7vJgXOLU VDdmzt9CTrZUW5Y6BfC5GBkJfz2/tVfpUHCh+g6yhU1IDBXkuXGnyV2sD/j5/OdQlFP8 O6gg== X-Gm-Message-State: AOAM533YC6TNgoCziNleyXIhnZnEMSYUcw4AM6jdOgo7+UYrX6EjTY6P R4CEiHimQe3LCSeLxG0fvBJoxH4Ek7+Ow8UbTExdzw== X-Google-Smtp-Source: ABdhPJyW/Wrt7bUG/89c/fzD04d9X82D1g8XApuWcWmK03ajobUKVm/GL1jZbXKtQNanl0srj0mIGUwHK9dwsGogc7s= X-Received: by 2002:a2e:9d8d:: with SMTP id c13mr7818512ljj.160.1605885292641; Fri, 20 Nov 2020 07:14:52 -0800 (PST) MIME-Version: 1.0 References: <55e200cf-ed16-e935-4e09-728ce3362cba@gmx.de> In-Reply-To: Date: Fri, 20 Nov 2020 09:14:41 -0600 Message-ID: To: David Rodrigues Cc: "Christoph M. Becker" , Dan Ackroyd , Hans Henrik Bergan , PHP internals Content-Type: multipart/alternative; boundary="0000000000006b205405b48b4e84" Subject: Re: [PHP-DEV] [RFC] Draft - Closure self reference From: pollita@php.net (Sara Golemon) --0000000000006b205405b48b4e84 Content-Type: text/plain; charset="UTF-8" On Wed, Nov 11, 2020 at 12:37 PM David Rodrigues wrote: > My suggestion is to reuse the keyword `as` to set a variable that will > represent its own closure. It is more flexible once that we could choose > any name and reuse in nested closures. It is pretty similar to how SQL > works too. > > function fn1() as $lambda1 { > return function() as $lambda2 use ($lambda1) { > return [ gettype($lambda1), gettype($lambda2) ]; > }; > } > > My initial reaction to this is: Technically doable (easy even), but looks a bit... ugly? weird? surprising? I think my main objection to it is how much is now stacked after the parameter list: function($args...) : returnType as $local use ($captures...) { ... }; That's a lot of... stuff (granted, we have most of it already) and how it looks when stacked together gets funky. Is it `returnType as $thing` ? That doesn't read well, but I don't see us making return type movable. as/use should be placable in either order, but maybe we give them required order anyway? TLDR; Long winded way to say I'm not inherently against this, and I like the idea of a lambda being able to recurse (not that I can ever recall having use for it, but maybe I fell back on named functions for that), I just think it's getting a bit wordy. -Sara --0000000000006b205405b48b4e84--