Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108487 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62783 invoked from network); 11 Feb 2020 18:25:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2020 18:25:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E58F31804F8 for ; Tue, 11 Feb 2020 08:39:15 -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,HTML_MESSAGE, 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-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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:39:15 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id x7so12361350ljc.1 for ; Tue, 11 Feb 2020 08:39:15 -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=5NegkOOdfk/0NFj9aGL+82uoye6sAOas4Gjf6sWj2u8=; b=U5+1Eao3KwWoBPv7VzIRfPbM/SpWW+yUZCHKKYSmlSsgipU9v/oGP9u/M3cV86UA6M 5F8/21LK6HCy44rMlWOrV2/zEigYa8RFMbYchwMUhB9yHfsKbZTTiN2DOTBDGsCQJrKr m0dMuXjRUGYArXhT5dH81+u8Xs0IPExDqo3RwnIbqSvKFb+ja5ooZpIN9ybdHy3exnjw 4CS47izJQEYL4HXMGBc4y6coh3z7mH/dRys8ZF+lwoVjjmj0sIp7jx0MMxStWxz/QPWy jNWOBS3OeNK2pobtTQgrw12RlfmM6Cnqp2hwDS3ZIMEaq2NTS9X3wiUpa12+6SoCFh6Z r/Rg== 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=5NegkOOdfk/0NFj9aGL+82uoye6sAOas4Gjf6sWj2u8=; b=rJfciVcB/P3x0rJz5NeHf9OmUq77W3Hxl+OmauqB0XYlmGjXIV6djz81lWFBSijKHS f3U+Sw3eB0reaPQZ0/gsbusk7lvRVaWD9/qkVia7zDoFBzBczc+0F401Da7HIHF+u8fa YrVIqOypCIqtHax8XlV0e/bJtjmovYeYr5Wd6vO03zJE0q2vYIOSFX7sFywiUOxGEnCP 50+TiYMfYlNb5payRdGKEpL5uQkNzsE+kd0Y2ZgwDYlbu5hzcLs6BBQQnrnZ7vDaayC6 LuTWB7+X/UtCDvVs0JQoV4qbBZxiQ+6kVhgk7yYLtW36DrA7WpreBeDUlE1AKp8mnbwW v3lQ== X-Gm-Message-State: APjAAAWyMt05Cu+eawgBuQNnP7fCSuLMmQmDw1BXxizLW6ZY80+UvrA/ cTCD7VQ9Q91EPTU6udq6DnKUnLuvG1lecQBtFTGI5c6a5pU= X-Google-Smtp-Source: APXvYqy8PKbfHTV/g9E75OLKOOn/mTzSTiJVcjNXbFcPSwF+1U/B6RJS9C3SbZJhub2M8da5RwAwnTE91X4ptPIktA8= X-Received: by 2002:a05:651c:8f:: with SMTP id 15mr4750706ljq.109.1581439152329; Tue, 11 Feb 2020 08:39:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 11 Feb 2020 17:39:00 +0100 Message-ID: To: Levi Morrison Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000e89893059e4f7e7d" Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) --000000000000e89893059e4f7e7d Content-Type: text/plain; charset="UTF-8" On Tue, 11 Feb 2020 at 16:27, Levi Morrison 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. Hi, Levi, 1. Yes 2. Yes, I agree 3. Wouldn't it be the opposite?. E.g: class Foo { static function run_callable(callable $callable) { $callable(); } private static function private_function() { echo "bar"; } } Foo::run_callable( [ 'Foo', 'private_function' ] ); Currently, this is valid. However, the following is fatal: class Foo { static function run_callable(callable $callable) { $callable(); } private static function private_function() { echo "bar"; } } Foo::run_callable(Closure::fromCallable(['Foo', 'private_function'])); The same with functions. If "::function" would retrieve a closure, some code could breaking when people switch string function syntax( e.g: 'strlen' ) to "::function" syntax( strlen::function ). On other hand, other option is ::callable, This is different to ::function, because it would affect to other callables, so that, returns could be other( Closure ) --000000000000e89893059e4f7e7d--