Re: [PHP-DEV] closures questions

2008-07-24 Thread Lukas Kahwe Smith
On 24.07.2008, at 11:10, Christian Seiler wrote: Personally, I don't care whether a object-to-string cast is present or not. So lets remove it? I don't think Closure can be meaningfully exported. Can we prohibit it? Unfortunately, currently not, see the var_export code. I think we can

Re: [PHP-DEV] closures questions

2008-07-24 Thread Christian Seiler
Hi! so do we even want the toString() method? IMHO we should drop toString from Closure. There is one case which *may* cause problems: function doSomething ($callback) { if (!is_callable ($callback)) { throw new Exception (...); } // special treatment if ($callback == 'default'

Re: [PHP-DEV] closures questions

2008-07-22 Thread Stanislav Malyshev
Hi! H, the amount of problems is pretty long. So even though it might sound cool to do it. It is the better deceision to not allow it. Also you've shown several paths where it would slow general execution down. Yet I hate not being able to easily make it work. Well, $foo->bar->__invoke() i

Re: [PHP-DEV] closures questions

2008-07-22 Thread Marcus Boerger
Hello Stanislav, Wednesday, July 23, 2008, 12:54:48 AM, you wrote: > Hi! >> Nope. It means if you have a function named foo and a property foo that >> sores a closure and then call foo(), then obviously the function is called >> rather than the closure. > That means you can't call the closure,

Re: [PHP-DEV] closures questions

2008-07-22 Thread Stanislav Malyshev
Hi! Nope. It means if you have a function named foo and a property foo that sores a closure and then call foo(), then obviously the function is called rather than the closure. That means you can't call the closure, and nothing alerts you of the problem. 2. We'd have to check properties eve

Re: [PHP-DEV] closures questions

2008-07-22 Thread Marcus Boerger
Hello Stanislav, Tuesday, July 22, 2008, 11:07:58 PM, you wrote: > Hi! >> Can't we change zend_std_get_method() to return a zend_internal_function >> struct in case of a closure on a property? The only thing that needs to > That means that: > 1. We can't have properties named same as functions

Re: [PHP-DEV] closures questions

2008-07-22 Thread Stanislav Malyshev
Hi! Can't we change zend_std_get_method() to return a zend_internal_function struct in case of a closure on a property? The only thing that needs to That means that: 1. We can't have properties named same as functions anymore 2. We'd have to check properties every time method name was not foun

Re: [PHP-DEV] closures questions

2008-07-22 Thread Marcus Boerger
Hello Stanislav, Tuesday, July 22, 2008, 10:08:11 PM, you wrote: > Hi! >> so do we even want the toString() method? > IMHO we should drop toString from Closure. Sam here. It makes no sense anyway. This mail thread just proved that. >>> Maybe it could return some relevant information for expor

Re: [PHP-DEV] closures questions

2008-07-22 Thread Marcus Boerger
Hello Lars, actually this is a very good idea and should work :-) marcus Tuesday, July 22, 2008, 10:15:03 PM, you wrote: > Hi Stas, > Am Dienstag, den 22.07.2008, 13:09 -0700 schrieb Stanislav Malyshev: > [...] >> I'm all for doing it, the problem is the syntax $foo->bar() is already >> us

Re: [PHP-DEV] closures questions

2008-07-22 Thread Lars Strojny
Hi Stas, Am Dienstag, den 22.07.2008, 13:09 -0700 schrieb Stanislav Malyshev: [...] > I'm all for doing it, the problem is the syntax $foo->bar() is already > used. But you can do $foo->bar->__invoke()! Can't we change zend_std_get_method() to return a zend_internal_function struct in case of a

Re: [PHP-DEV] closures questions

2008-07-22 Thread Stanislav Malyshev
Hi! Hm, I'm not sure who expected it that way. At least Stas and myself voted *for* allowing it. We need to discuss the semantics (the order how methods are resolved, interceptors) but I had the feeling that most of use really much liked that feature. I'm all for doing it, the problem is the s

Re: [PHP-DEV] closures questions

2008-07-22 Thread Stanislav Malyshev
Hi! so do we even want the toString() method? IMHO we should drop toString from Closure. Maybe it could return some relevant information for exporting the closure across data not a huge biggy to me. I don't think Closure can be meaningfully exported. Can we prohibit it? I guess this is

Re: [PHP-DEV] closures questions

2008-07-22 Thread Lars Strojny
Hi Christian, Am Dienstag, den 22.07.2008, 14:15 +0200 schrieb Christian Seiler: > > >> Calling: $a->b(); will result in method A::B() does not exists. > > Yes, that's expected behaviour (we had a few comments on this on the > list). Hm, I'm not sure who expected it that way. At least Stas and

Re: [PHP-DEV] closures questions

2008-07-22 Thread Christian Seiler
Hi Lukas, 1) Closures on class properties just don't work, the only way to do it is to do something like: $c = $a->b; $c(); Calling: $a->b(); will result in method A::B() does not exists. Yes, that's expected behaviour (we had a few comments on this on the list). Compare this to, for example

Re: [PHP-DEV] closures questions

2008-07-22 Thread Lukas Kahwe Smith
On 22.07.2008, at 13:04, Lukas Kahwe Smith wrote: 1) Closures on class properties just don't work, the only way to do it is to do something like: $c = $a->b; $c(); Calling: $a->b(); will result in method A::B() does not exists. would be nice to get this fixed, but at worst it should be do

[PHP-DEV] closures questions

2008-07-22 Thread Lukas Kahwe Smith
Hi, I am sending this on behalf of Kalle: 1) Closures on class properties just don't work, the only way to do it is to do something like: $c = $a->b; $c(); Calling: $a->b(); will result in method A::B() does not exists. 2) Closures can be defined as constants values because of its toString