Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108528 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49523 invoked from network); 13 Feb 2020 05:19:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Feb 2020 05:19:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0F51D1804AC for ; Wed, 12 Feb 2020 19:33:40 -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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 ; Wed, 12 Feb 2020 19:33:39 -0800 (PST) Received: by mail-yb1-f169.google.com with SMTP id b141so2289109ybg.10 for ; Wed, 12 Feb 2020 19:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=g/+hZgGfXzS91YAixP3eqPho9SV3CG2yN0VWSYRW86M=; b=v+V1LJ/i+VnNpteusf2zS2b16/nEaUi/E/MJ+hT8PmEjvzZEkZQD7zMdlXNUQVnZuF fHgP2G+hgtNfC4h1MrVq8guFp5G86OZ6QjLuRqfSWKbt9N1UNxAGSLRFVxzf+BETD+iK ltqmzKoilRYylkpW5vPEC3FyWQfYP8DKLSird0od8OuX/2AhB3BRGax1rbDbh1XpODox Bjju9fHq4J/yWEhfJ/9L7BGiticBErd6Yn77ylChHSwwyBDeU4VGqZNdwDW1TGFDtH5s EkchU+Ywb74sWFxBsYsCrI8sLvQ5PDz4Gv3BwqP7g1G5Y/vqPXu4x/jDoczIgEm7FD2Z y4cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=g/+hZgGfXzS91YAixP3eqPho9SV3CG2yN0VWSYRW86M=; b=bL3pvrg1aAHLEPRBOAoAGcqqxc39gu7/UmCnJFqXhEkYWgofP5zevOmQkaAc+UdnwW Bwi9c20hVulZRXjB40MWRQ98r7JV7H0ecDYcB9c+t8wsdHdJfHJd8A6P+9xnqALwFWhv Dcan181cWdb5Nk4mnme9T/JCmBX6N2eBGt/vW2ZkoF4QKMW4O57Owk4fY+Xg7OE+kBrr aXsvSfO6hyLt7GV5soe+d5YtbO8JBDxwC9wHLgPSvawQbZnSCe+Lay+gG+GOE1oCVoUN EBLZt7J3M8LVGYuS5IIN/MY++WOWfI+e79PzHgOCiqWRMarwzf3FCaQaDqZkKcV6K3/e R/bQ== X-Gm-Message-State: APjAAAWyol27XP2wEFBDWXXEIBuHnMWc48le8e2BJ9iR+UAejDPXcRub e8xVCy+WOVyQJN/+Qbwfala31g== X-Google-Smtp-Source: APXvYqx5svISIqyMy1sUJMli3fTmg/Q/WXSskS5vY4mLwxDp4MDw5O4GdOCLuYEzq4TkJEuw+29neA== X-Received: by 2002:a25:e013:: with SMTP id x19mr13710229ybg.45.1581564814199; Wed, 12 Feb 2020 19:33:34 -0800 (PST) Received: from ?IPv6:2601:c0:c680:5cc0:c40d:6267:8a93:b5b9? ([2601:c0:c680:5cc0:c40d:6267:8a93:b5b9]) by smtp.gmail.com with ESMTPSA id m62sm518925ywb.107.2020.02.12.19.33.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Feb 2020 19:33:33 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Wed, 12 Feb 2020 22:33:32 -0500 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Rowan Tommins X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] [RFC] From: mike@newclarity.net (Mike Schinkel) > On Feb 12, 2020, at 5:47 PM, Rowan Tommins = wrote: >=20 > On 12/02/2020 03:58, Mike Schinkel wrote: >> Returning a_closure_ instead of a string would be providing a = feature we_already_ have instead of one we do_not_ have. >=20 >=20 > Not really, because you still need a way to get the fully-qualified = name of the function. This is not valid: >=20 > namespace MyVendor\Something\Foo; > function bar() {} >=20 > \Closure::fromCallable('bar'); # Error: tries to resolve function = '\bar' >=20 Why would ::function return a short name instead of the fully-qualified = name?=20 ::function should return the fully-qualified name as does ::class. Then = the concern you state becomes a non-issue. If ::function returns a fully qualified name developers can always use = string functions to get the short name if they need it. > So if we had ::function which returned the name, and ::callable that = returned a closure, the following would be equivalent: >=20 > namespace MyVendor\Something\Foo; > function bar() {} >=20 > \Closure::fromCallable('MyVendor\Something\Foo\bar'); > \Closure::fromCallable(bar::function); > bar::callable; >=20 > One combination would be ::function returning a string, and $() = accepting one, which would give: >=20 > $(bar::function) >=20 > In practice, that would almost certainly be optimised into one = instruction, so the main advantage would be consistency, unless there = are use cases where a string rather than "any callable" is actually = required. Yes. >> Or today just use fn() =3D> myfunc(). >=20 >=20 > That's not quite the same either: at the very least, you need to = define it as fn(...$args) =3D> myfunc(...$args) to pass through the = parameters. Assuming there are parameters. > But Closure::callable is able to copy the signature of the original = function, including type information [1], so our hypothetical ::callable = could do the same. True. ------- As an aside, I wish we had a new simpler form of metadata object that = could provide the features of reflection quicker and easier and one that = didn't need to be wrapped in a try{}catch{}. Something like this: - https://gist.github.com/mikeschinkel/78684d708358e1d101e319c7a2fdef9c But this being PHP =E2=80=94 with its love of verbosity and complexity = when adding classes, and disdain for adding something if a capability = already exists, no matter how cumbersome it is =E2=80=94 chances of this = becoming a thing is pretty much moot. So I am just pontificating. -Mike=