Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115279 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52599 invoked from network); 2 Jul 2021 22:00:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Jul 2021 22:00:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AAC6B1804C4 for ; Fri, 2 Jul 2021 15:21:29 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (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, 2 Jul 2021 15:21:29 -0700 (PDT) Received: by mail-yb1-f178.google.com with SMTP id k184so18635193ybf.12 for ; Fri, 02 Jul 2021 15:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=db25dkMxTsgQ22mXYXWEXeTg3UOvvB6xmogu9xGV3j0=; b=KeJgjOQbWglxskjjlthGZ19pfJ/Meh4qLsbZwl2K56SAgqBa9Pf2rwyrSUCsMzXR1h P3ZQGfrrbnuTZPYZcrPtqtnbz++pFOWXT2eczKDoVidPesBOSfvnsUdnmNN/oNaFnTNi //H684WLv3P8QZE7MicwXK/B2IeKMjMlAptkU= 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=db25dkMxTsgQ22mXYXWEXeTg3UOvvB6xmogu9xGV3j0=; b=o928bJPApYwvgntnU9MaPcYH3DnX8P33k4QjE9zg5cQcXqH7d/pxkwqgMqF2LcG7hs lYrVG6jENwhNriZ0N6Oeg5DI18jM/Si/P4H4UuAfQvSrOkCH14Y11f9QbeTQF/7106np 7B7Qgx+SJmTMFaQly4zDGOTn3oZJgpE6bCkOXh4+7eC64jMIit+si4oeMJ1U4UZwAgRc +KYvCW+RzWnoWShlEtYXKVdA+9i8y+4QXWt0hkMarIpAojxnv3UAfOyrT2rXhc3kvl3n irusW5T4UxtPz4ORInjy5GA2VgBjNm753r41J+CNpkPsMD3Q440Yp+BWD/tGtmkwHKuh z2TA== X-Gm-Message-State: AOAM5304lFeE1TKihL1HrbV3OSG+PpUAgljDyxo0WHsYAVp3lEIjCpGW ZBCpUN1fi/UoQB/01bFYer+Djg/iPYQQx+kGM/E9mozwvdO2xQ== X-Google-Smtp-Source: ABdhPJzHGPjRq7J3bGzNr01qrpKwIFQ1/hlE2gJtEeUprawAIgXYZTHPPbhkHPQ06lnfpLYZQCgpt3S3qE5A31hT7y8= X-Received: by 2002:a25:cec4:: with SMTP id x187mr2115489ybe.402.1625264485405; Fri, 02 Jul 2021 15:21:25 -0700 (PDT) MIME-Version: 1.0 References: <802fdb7d-69e5-edfa-de94-70416f9093d0@ralphschindler.com> In-Reply-To: <802fdb7d-69e5-edfa-de94-70416f9093d0@ralphschindler.com> Reply-To: Levi Morrison Date: Fri, 2 Jul 2021 16:21:14 -0600 Message-ID: To: Ralph Schindler Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [VOTE] First-class callable syntax From: internals@lists.php.net ("Levi Morrison via internals") On Fri, Jul 2, 2021 at 10:32 AM Ralph Schindler wrote: > > > > This RFC uses a syntax that is forward-compatible with partial function > > application. Should it not be accepted, I'll explore alternative syntax > > possibilities. > > Given the choice of syntax in this proposal (which I do like)... Is the > following (potentially future) use case precluded by the syntax (whether > or not you like it immediately ;) )? > > Basically be able to: > > 1. be able to refer to an instance method statically (this is currently > an error) > > 2. allow late binding of $this/context/closure scope, either via > bindTo() or via Reflection setClosureThis() (does not exist) > > > > class MyController { > public function myAction($name) { > return new Response("Hello, $name"); > } > } > > // Closure with no $this (to be filled in later) > $fn = MyController->myAction(...); > > > $controller = new MyController; > $response = ($fn->bindTo($controller))($params); It would theoretically be: $fn = MyController::myAction(...); It currently errors: > Fatal error: Uncaught Error: Non-static method MyController::myAction() cannot be called statically I would be okay with allowing this, as long as it's bound before it's called.