Hacker Newsnew | comments | show | ask | jobs | submit login

But doesn't it lead itself to "Action at distance" anti pattern?

Like everyone else, we use django-regsitration a lot. Here in your code, http://bitbucket.org/ubernostrum/django-registration/src/tip... you send a custom signal. Now any one can break the normal flow of control and call control _from any where in the project to anywhere in the project_.




Signals defines a fairly concise interface for interacting with events.

You're not "stealing" control from the loop. Rather, think of it more as listening and attaching something to an event.

For me, it helps to think of signals less as interrupts in a traditional program loop, but as something more akin to events in event-driven environments.

-----


   break the normal flow of control
But after the signal is fired, and handlers do their handling, normal flow is restored and the code just after the signal resumes (assuming no exceptions were thrown). COMEFROM doesn't make that guarantee, making it much harder to follow.

It isn't that code can jump to an arbitrary point in the program (a function call can do that) but that the code after that point won't get called, barring a corresponding GOTO back to the label.

-----




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: