Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108494 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 86913 invoked from network); 11 Feb 2020 20:32:41 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2020 20:32:41 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9023C180539 for ; Tue, 11 Feb 2020 10:46:38 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_NONE,SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Feb 2020 10:46:37 -0800 (PST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id B7FF04C9 for ; Tue, 11 Feb 2020 13:46:36 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Tue, 11 Feb 2020 13:46:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=+wMFtf Mmx97wYtPGl5cIRIotuN8gLqEg8axBXu9JHCM=; b=Rb3MW3jhfBqyzKfSYcSNIW /L97KF9yM40eG1Hnml/7eWCgNzvPj/YdsYpuhH7PiX5tDy1EZzkqcZs9Ki5mRmok mZFUE0I9lOA5BpAgZ161PocFMeqeH9KnVxc4CC6n3Gki2x6rC0hd5Fyb1fQwS0O/ yV1RDWGfGimnsUuLe5h0+8ZJhXA4pxelhMI02TDr2vshvTfeypmkFtq3hVYh0hsi hJfkSHmekl+NNhEAEy6yTtf7nBmZJ+w+AXOO8EOZ9Rk89YFPGHzgH4ivKV98Lsvf 0JZeVJyiD+OFVjZREsWotSFZeAy+1EV6+yp0zZ1T9Svv+SQJmQaIxvhZn2TSuLiA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrieefgdduuddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehl rghrrhihsehgrghrfhhivghlughtvggthhdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id E0A1714200A2; Tue, 11 Feb 2020 13:46:35 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-802-g7a41c81-fmstable-20200203v1 Mime-Version: 1.0 Message-ID: <0c6f16a8-a6f1-4adf-9264-a23300bbe2c7@www.fastmail.com> In-Reply-To: References: Date: Tue, 11 Feb 2020 12:46:12 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] From: larry@garfieldtech.com ("Larry Garfield") On Tue, Feb 11, 2020, at 9:27 AM, Levi Morrison via internals wrote: > I have three immediate thoughts: > > 1. It should be `fn` or `function`; reserving a new word even if it's > contextual is pointless here. > 2. It should support methods. > 3. It should return a closure, not a string. The reason is for > consistency with methods, where we want to capture the scope at the > time the closure is created, not ran. Imagine passing a private method > as a callback; if it was done via `[$obj, 'privatemethod']` then it > will fail at runtime, because the scope it's called in doesn't have > access. I would love a nicer way to reference function names; it's really ugly to do functional code in PHP otherwise, or even just dynamic function logic within a namespace. If I never have to write $fn = __NAMESPACE__ . '\a_func' again, it will be too soon. :-) I agree with Levi on points 2 and 3, for reasons already stated. For bikeshedding on the syntax to use, I defer to the engine authors who can say what is possible to implement. However, the guideline should be *short*. If we make referencing a function too verbose, no one will want to use it and readability will be harmed. Double-whammy. That's why I'd say adding ten characters (::function) is a definite no-no. ::fn would work. There was previous discussion of ::name, which could then also apply to classes and objects. That would be acceptable, I think. Other alternatives like &(funName) et al are also fine if they actually work; Again, I defer to the implementers on that. But in general, yes please! --Larry Garfield