3 ms·
I have a couple of deployed applications where I've found similar patterns of advanced control flow. In one case, a mixture of early exits and exception handlin
by chromatic 15y ago
I have a couple of deployed applications where I've found similar patterns of advanced control flow. In one case, a mixture of early exits and exception handling is boilerplate repeated dozens of times. I prefer not to copy and paste all of that code, but the only other abstraction technique Perl 5 gives me right now is to extract this behavior to some sort of Command Pattern object system, and that seems like a lot of complexity both in design and in surface syntax for what's just standard control flow.
Another pattern I use quite a bit is to write an parent application class which has the scheduling and task management behaviors of several subclasses (these subclasses each have separate and idempotent behaviors, such as "fetch newest data from remote server" or "republish static data from templates"). Most of the core behavior of each application is "loop over a task queue and process each individual element", the specific details of each task are so different that it's difficult to abstract further to push more behavior into the superclass. I could go further and use more higher-order functions, but there's a point at which you're building up a long chain of closures closing over closures just to avoid writing a loop, and I'm not sure that's practical.
Basically I want parametric custom control flow.
- kamaal 15y agoInteresting, Can you please illustrate with an example how this could possibly end up looking like? Will be nice to have something like this.