Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114546 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76953 invoked from network); 20 May 2021 19:44:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 May 2021 19:44:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 126C318050A for ; Thu, 20 May 2021 12:54:20 -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,FREEMAIL_FROM,NICE_REPLY_A, 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-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 ; Thu, 20 May 2021 12:54:19 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id c14so17060245wrx.3 for ; Thu, 20 May 2021 12:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=tgi1UiIWbnIvuoPoNwQzA0NuMpigiWfBPx9WXmfq+OM=; b=khLTMc5TUn0HA3lJOIGBRji90JsB1b45Q1HAdTMoIkciWUwmKa5uz2tpNLlBYjVn2r C5CDFo5fmxpW1/iLanAtKwT78AgXH0geYAUxETw0H9hLJ8CWZm/a/EsNCuFUZoA/zs+F s+fBl/Yj+mS3+tK35U1cZrLzpdJkQsB0WBW2GddOWV5J0Qvowz7PkMqelp1+qVzdVqOq +SGXmUGZwNQDg7/qFg+wUfouFRHg0UfJS4fSyLRO+yFChOohnfWUFdkY97xTJLHHs3GA 3UrM2sP6wi2fih83gG/h9rzVNnuN1hJVMq+B/BoZ5KiVd1loc3Q2hKE8F36P59EbA8vw Fa2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=tgi1UiIWbnIvuoPoNwQzA0NuMpigiWfBPx9WXmfq+OM=; b=eFVHfrZMKC+qXqGRZM5G1EkmURxBAvVxW0Yon0/7yAEdzBo9ooJfklG4Ep+RldW69X MXnJRz/3aKeCoVHcdqitSVXfIip/YzHI9hOkahoahxlocE5BPW4dggtFABEl3c23uwuO p6A+ohecQCv/OURK6gNTpLuO66ZKpEhS+SuFTbfPLZZdMk5nVshUl58t5x6vLjnKeAqQ 3rcvCeJ64HxqistC62Gq+M6XvvJ/DCe/C/NeCnh6SGQiuITvYtpyPws5sVHZxnOwSA/O mhCrQ/80sDOWhPzDriykgImnRiENEJuj5SpuT5mj8LrkkWoVWo7F91uY8wXKwa8CNepO auwQ== X-Gm-Message-State: AOAM530oaRtWosGr/3srD6O4j0aJAz7NvHkOK2s97kSZtdRBB2v8bN9j gnFW3imt0n3i9vycEfGpYRlRHWzgMvI= X-Google-Smtp-Source: ABdhPJyAOIzJ0HD91J2RLtKr7VJhoY3JNq6c2Pqe3LMVhDKxSKFS/D8jazdhfFyZ2h73PXKt3lu5LQ== X-Received: by 2002:a5d:500b:: with SMTP id e11mr5897857wrt.209.1621540456977; Thu, 20 May 2021 12:54:16 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id v12sm4249263wru.73.2021.05.20.12.54.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 May 2021 12:54:16 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <1a024ec2-60c0-4a48-5f1e-4a4369a6a642@gmail.com> Date: Thu, 20 May 2021 20:54:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] First-class callable syntax From: rowan.collins@gmail.com (Rowan Tommins) On 20/05/2021 19:16, Alexandru Pătrănescu wrote: > Also, considering the resolution between property and method (or between > constants and static methods) , it's clear that we need a syntax that looks > like the usual invocation:(...), or (?), (...?), ($), ($$), (...$) etc. I'd like to expand on this point, because I'm seeing a lot of suggestions for syntaxes that overlook it. The following are all valid, but refer to _different_ things called "foo": foo // a constant called foo foo() // a function called foo $foo // a variable called foo $bar->foo // a property called foo $bar->foo() // a method called foo Bar::foo // a class constant Bar::foo() // a static method Bar::$foo // a static property The thing that consistently distinguishes function and method calls is the parentheses after them. This holds even for "exotic" combinations: $foo() // a variable called foo, de-referenced as a callable and then invoked ($bar->foo)() // a property called foo, de-referenced as a callable and then invoked foo()() // a function called foo, the return value of which is de-referenced as a callable and invoked Any callable syntax (and, if/when we get one, a partial application syntax) that doesn't have the parentheses there is going to run into annoying edge cases fast. Not necessarily the kind of edge cases that are hard for the parser, but definitely the kind that are confusing to humans. Regards, -- Rowan Tommins [IMSoP]