On Thu, 13 Feb 2020 at 17:06, Mike Schinkel <m...@newclarity.net> wrote:

> 1. IF foo::function returns a name string THEN using
> Closure::fromCallable( foo::function ) can provide a closure.
>
> 2. IF foo::function returns a closure THEN how to we get the name string?
>


Right, I'm with you now. However, I think the answer people are suggesting
to "how do we get the name string?" is "why do we need to?"

Or as Chase Peeler more eloquently put it:

> Can anyone think of a use-case where you would want a string name of a
> function and a callable would not be acceptable, besides possibly
debugging
> code that said 'echo "I'm calling ".myfunction::function;'? Everything
that
> I can think of that accepts a function name, also accepts a callable
(e.g.
> array_map), but I could be forgetting something.


There's a Venn diagram, essentially, of:
a) use cases where a Closure would be useful, but a string wouldn't
b) use cases where a string would be useful, but a Closure wouldn't
c) use cases where either a string or a Closure would be useful

If (and it's a genuine open question) all the use cases fall into
categories (a) and (c), we can make the syntax for closures simpler by
skipping the "get name" step and making foo::fn return a closure straight
away.

So the question is, are there use cases that fall into category (b)?


Regards,
-- 
Rowan Tommins
[IMSoP]

Reply via email to