On Thu, Jun 19, 2008 at 8:44 AM, Andi Gutmans <[EMAIL PROTECTED]> wrote:
>> >> - In PHP 5, object storage is resources done right. I don't think
>> >> we should be using the resource infrastructure for this
>> >> implementation and would prefer to use the object one. It's better.
>> >> I suggest to take a look at it.
>>
>> Hmm, seems like a good idea. If nobody objects in the next few days,
>> I'll rewrite my patch to use objects instead of resources. What class
>> name do you suggest?
>
> Great. I think Closure is probably a good name.
> [Btw, if we want to get fancy we could even have a __toString() method on 
> those which would print out information about the Closure. But this is not a 
> must, just something which eventually could be nice for debugging purposes...]
>

Using objects, instead of resources is an excellent idea. Would it be
possible to introduce a general __invoke (Or whatever name is more
fitting) magic-method, so that whichever object implements that
method, is callable with call_user_func (and directly through
variable-function-syntax). Eg.:
class Foo {
  function __invoke($thing) {
    echo "Foo: " . $thing;
  }
}

$foo = new Foo();
$foo("bar"); // > echoes "Foo: bar"

I'm not sure how this would play together with lexical scope?

--
troels

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

Reply via email to