Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108492 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76930 invoked from network); 11 Feb 2020 19:28:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2020 19:28:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E611C180541 for ; Tue, 11 Feb 2020 09:41:59 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (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 ; Tue, 11 Feb 2020 09:41:59 -0800 (PST) Received: by mail-lf1-f67.google.com with SMTP id l18so7627298lfc.1 for ; Tue, 11 Feb 2020 09:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GiH+yjdva9zvQlRe6jZmuOpmO4HNe+lCJlA6n0rPiHI=; b=u/XoHDQm8eTSp2X+OLDpAM4bhOEdvRBYUctmCesTQ1O/Aub/HkSYbMjQ6jw0JTYr1I NvrVoAPrMgdXVFnb+7eQzcsC+7JCnNmQFYQpPhufWPow416w/NNUveQlypy5GPMSAuBH kGo75wetAEDtLEZzTVpJYRFvFIZyhsJBrx004sV9p8/KR75yBF0Ph0KKzMVYMsPpzauT +fFNSF3F+auaE8L4taWIpYuOJ2RAs6iyLD5SVzPzjez65QE9goOdMDwh4gY+0HL00vxA tbvqnN5SFgj8EKd7Ek+T9mbU1LezHyY6vHLXj9r2str+J4YOo/1XCTrnpXQF+faESqhb PXKw== 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=GiH+yjdva9zvQlRe6jZmuOpmO4HNe+lCJlA6n0rPiHI=; b=X4uAFiMS0Tm3bSeQfQ1BR1Vha0/XvAmELYfYKifOGKWnCyYdlccBkyMq1aSeH7x+8X gNlhqAKUyLLhQTheRHvkML+APTsinP7eaUFmMcJKZGjR6x6nvx2sRbbx7kro9RXogO/G 0ANLnTdozwyuO3HmeeYJ6ivAx93tl5rtChGXXapAAOESw6RCcJHiz/8bFZAuIzACx7YT Op9asOAL6pqd3OFJnVUxoMS9UJ7jpEXDnUHR+xTRdt0Wz685rcgN27kBIYMHqbTtqnTo yh1/WmutkB+ipmzY6r5gB2QS+j8M9YzXzfPID7QBX5UnjdPoSl3UuMbO3pjoYnPbT6sD 1Ygw== X-Gm-Message-State: APjAAAXV0wxc7yFnKjuEdIltp4Ca0ZnOZrkEwJ1CVQXOuUFrLoXo3cvy 30coDFtJlNwGQ4eIBgeInsRPMiVveuA3xAdFXzg= X-Google-Smtp-Source: APXvYqw9mpTR3P6tO/9hXoMUvFDL0ofpl+Q4Vdsf7JMz68MUUIHqKXkGa8fxp18frZ4dd4Yd9igQOAq9YMkMEYceh1U= X-Received: by 2002:a19:f608:: with SMTP id x8mr4148593lfe.115.1581442917211; Tue, 11 Feb 2020 09:41:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 11 Feb 2020 18:41:45 +0100 Message-ID: To: Dan Ackroyd Cc: Nicolas Grekas , Diogo Galvao , PHP Internals List , Nikita Popov Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) On Tue, 11 Feb 2020 at 17:49, Dan Ackroyd wrote: > > Nicolas Grekas wrote: > > I wish this would return a Closure instead, making $foo::function the > > equivalent of Closure::fromCallable($foo). > > I didn't include the following in that RFC, because I thought it would > be too controversial, but I think it's worth considering a new syntax > for this. > > Given the code: > > function foo(); > class Zoq { > public function Fot() {} > public static function Pik() {} > } > $obj = new Zoq(); > > > Then these: > > $(foo); > $($obj, Fot); > $(Zoq, Fot); > > Would be equivalent to: > > Closure::fromCallable('foo'); > Closure::fromCallable([$obj, 'Fot']); > Closure::fromCallable('Zoq::Fot'); or Closure::fromCallable(['Zoq', 'Fot']); > > Or similar. > > The justification for having a dedicated syntax is that I think > readability is quite important in code, and it's reasonably common for > me to have quite long lists of 'callables'. > > [Bar::class, foo1::function], > [Bar::class, foo2::function], > [Bar::class, foo3::function], > [Bar::class, foo4::function] > > vs > > $(Bar, foo1), > $(Bar, foo2), > $(Bar, foo3), > $(Bar, foo4) > > The latter is far easier to read for me. > > Nikita Popov wrote: > > This would circumvent all the issues outlined in > > https://wiki.php.net/rfc/consistent_callables. > > Probably there would still be some issues with some of the weird stuff > happening internally in SPL related code where the deep horrors > rest...but we can leave them alone...and they might not wake. > > cheers > Dan > Ack Other option: Closure::fromCallable('foo'); Closure::fromCallable([$obj, 'Fot']); Closure::fromCallable('Zoq::Fot'); or Closure::fromCallable(['Zoq', 'Fot']); to <$foo, Fot> E.g: array_map(, $array); array_map(, $array); Do you like ?