Re: Annotation PHP 7
| From: | Sean Coates | Date: | Tue, 04 Nov 2014 20:11:05 +0000 |
| Subject: | Re: Annotation PHP 7 | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78678@lists.php.net to get a copy of this message | ||
>> In Python, decorators are very
>> powerful for modifying function behavior (i.e., attaching pre/post
>> conditions to functions or doing some things phpunit does is really
>> easy) but it is too much for just attaching data.
FWIW (and I apologize if this is just adding to the noise), one of the most powerful things about
decorators in Python is that the decorator can do different things in different contexts.
For example, in the web-app context
@app.task might cause a function’s execution be
deferred, and return quickly so the actual work can be carried out by another process.
In a worker context, @app.task could be used to define the work that should actually be
carried out by the current worker.
Reference for those interested in a practical example: http://celery.readthedocs.org/en/latest/userguide/tasks.html
S