Ondřej Mirtes wrote: > Hi, I’m confused by the syntax, when I read it,...
That is true of almost any new syntax. Some of us are still getting used to seeing \ in front of function calls. It doesn't mean that the syntax choice is a bad one, just that it's something new. For me, the main questions I ask myself is: * could I explain what the syntax means to a junior developer? * would the junior developer be able to remember it? For both of those questions, the suggested syntax seems fine. Guilliam Xavier wrote: > I wouldn't want to start new bikeshedding here; is there a > place that would be more appropriate to gather the possibilities Unfortunately I don't think we do have a better place. Being able to fork conversations so that "not completely off-topic, but not really that productive and getting in the way of the main discussion stuff", can be out of the way, but findable, is a feature that would be really useful for discussions. Nikita Popov wrote: > I am generally open to using a different syntax, Well, you might regret saying that. It might not be appropriate*, but having $() as marking a closure/callable seems 'clean' to me. Though obviously novel and likely to cause gut reactions: $(strlen); $($foo, bar); $(Foo, quux); $($foo->fn); $($foo); $($fn); Each would be equivalent to: Closure::fromCallable('strlen'); Closure::fromCallable([$foo, 'bar']); Closure::fromCallable([Foo::class, 'quux']); // aka Closure::fromCallable('Foo::quux'); Closure::fromCallable($foo->fn); Closure::fromCallable($foo); Closure::fromCallable($fn); For the code: class Foo { public $fn; public function __construct($fn) { $this->fn = $fn; } public function bar() { } public static function quux() { } public function __invoke() { } } $fn = function() { echo "I am function\n"; }; $foo = new Foo($fn); cheers Dan Ack * at least in the sense that it's a big syntax change, for a relatively small feature. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php