Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108488 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65319 invoked from network); 11 Feb 2020 18:35:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2020 18:35:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4F78118053D for ; Tue, 11 Feb 2020 08:49:07 -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-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) (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 08:49:06 -0800 (PST) Received: by mail-vs1-f42.google.com with SMTP id r18so6725720vso.5 for ; Tue, 11 Feb 2020 08:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G+dw8uT8MzYitDS3cwR6YpigIfmUJXI53glyzZ6sCWI=; b=JgqDg3+T2TRox5tquIbjxilbynnlEEx7xkIxwpqy0DRp8BSWf3IlN/+W++ke3cDkFK sQmsBfX4kv6Pqdolq58baXBSV2D0GBIUUf4CO3Nks82cO8fLXIrTSFBJ002WJ0v4Z4UI 2DtUWavZFI15zutgXzuteY6bh3s/HZ5t14ZQANxBW/p6/HVL8oUn1RkBEIA96XzTzKPy lMvSNwgFHRNaZgixrDJP1RIPS12YrhoO9mMrU8QhgB/eBNmDoWRRHQRvszHdOF8V/AzI qtBp9rxifvw5s+UnSSygUyRAPeyDeP1KSBvKvVScyFrSpkYTXSFR6P8c+VPr2HU+VujI /vgA== 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=G+dw8uT8MzYitDS3cwR6YpigIfmUJXI53glyzZ6sCWI=; b=SdRBKCdf+qFn4I2MRgXDw7ev22bU7C+VpBknvgSNhMB9uI/tQ1seAtkUjQo68JB3MS jLd295lXzO5ngnt7TdkPrnXxTr/YNtTtzo7hSvN57mR4359i8b9NBdTAHLbZndDulSAp oLhE28e+ObTt78NkLiHQy8EcgGFSrBbQ4aYmVY5ImeyFWjbczQS1llGAA2r1FA9kF9yc A8HkudoDqJME24NatCDgOwIPgjzN7YwXQGKX18YtEiyRp8h2gDRdpNv42cEWGkok7Nvk dC0f14zxs5CCgn3gqhYJ4q1iEQkwhEMDVkv3E4PMzxukpHwzNDdvJetmiro7MzLlSJRj WG/w== X-Gm-Message-State: APjAAAV6g1ghPK+yOBAb/ZeKE7nBLpae8eP2EcqsZEFzwZ+1tWAFwYFN VI3zWTOKi/RtIWRmBBSING23SW86k+2GyVQG5GyfXA== X-Google-Smtp-Source: APXvYqw8y/wPIrVdvX1LXC5NYKobxq6bSvU1Q25dLDuiSCSchOFjAKxOhpas5UfCdYcBceZutmA/3cdJ+tIIk7FLSeU= X-Received: by 2002:a67:7987:: with SMTP id u129mr9836996vsc.83.1581439744225; Tue, 11 Feb 2020 08:49:04 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 11 Feb 2020 16:48:53 +0000 Message-ID: To: Nicolas Grekas Cc: Diogo Galvao , Manuel Canga , PHP Internals List , Nikita Popov Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] From: Danack@basereality.com (Dan Ackroyd) 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