Re: [RFC] Closure::call and Function Referencing as Closures

From: Date: Sun, 10 Aug 2014 21:06:38 +0000
Subject: Re: [RFC] Closure::call and Function Referencing as Closures
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-76418@lists.php.net to get a copy of this message
On 10 Aug 2014, at 22:00, Rowan Collins <rowan.collins@gmail.com> wrote: > You're rather pre-supposing the proposed syntax there, and letting it lead the semantics > rather than vice versa. The point is it would be useful to allow creation of a pre-bound closure > based on an existing method, so it would be good if the syntax allowed that possibility. Huh? I’m saying it should do the same thing calls do for the sake of consistency. It’d be nice if (&$foo->method) could work, but sadly it doesn’t. > Getting a static reference to a non-static method and then binding it feels a bit like JS, > which has a completely different notion of what a method is. JavaScript’s methods are bound based on what object they’re used on. PHP’s methods are statically bound. That’s not quite the same thing at all. >> Using the ‘Closure’ class is unfortunate, but I don’t really want to >> make unnecessary new Function/Method/etc. classes given they’d all >> share the same implementation anyway. > > I'm not so sure they'd be identical - a static method or plain function would > presumably error if you tried to bind it, for instance. So do static closures, as I’ve already mentioned. I don’t really see what’s wrong with using our existing class for functions. -- Andrea Faulds http://ajf.me/

« previous php.internals (#76418) next »