Hi!

> It doesn’t collide, there is no syntactical ambiguity at an engine
> level, at least. It does unfortunately look similar, however. The

That's the collision. It looks exactly the same, but does entirely
different thing. This is not good.

> choice of syntax is largely for a lack of better alternatives. It
> also matches what C and C++ do. I had wanted to do something like

It doesn't match what C and C++ do - it does a completely different
thing from what C and C++ do. It's not an address and it's not a reference.

> The hope is that it’d be more obvious a function is being referenced
> without needing to know the signature of the function to which the

I don't understand how for writing "strlen" you need to know its signature.

> callable is being passed. I suppose it also means you could type hint
> for Closure instead of callable to guarantee you get an object you
> can use the Closure methods on.

Didn't we add "callable" exactly for identifying callables? So now
callable is not enough and we need also typing by Closure? But wait,
callable is still supported for calling, so what you want to do with
Closure? Right now it has two methods - for binding - and both are not
guaranteed to work at all - as you just said, it would fail to work on
any internal function and on most non-internal functions too, since they
have no idea what to do when bound. So you get an object that actually
guarantees nothing at all.

> PHP’s functions aren’t first-class, we just have a way to reference
> them with strings. What we do is similar to what C does with function

In what meaning they are not first-class that your change is making them
first-class?

> pointers. An advantage of being able to get normal functions and
> methods as closures is it means that anything we add to the Closure
> class can be used on them. For example, if we added built-in partial

But it can not. E.g. you can not bind such things. They can not have
environments. They only thing you can do with them is call them - but
you can do it right now!

> application (something I’d sure like to see, it’s just difficult to
> implement), you’d be able to use it on any existing userland or

You can do partial application to any callable just now by generating an
anon function that applies it via call_use_function. The only thing
introducing Closure there would change is how the method being called is
named.

> extension function. If we added built-in currying, a related feature,
> you’d also be able to use it. The syntax means PHP no longer has two
> classes of functions, essentially.

We don't have two classes of functions right now. If you go to engine
level, we have more than that, if you stay on PHP level, you just have
callable, which is not really a function but rather a way to address a
function.
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to