3 ms·
... macros would make what is already a fairly large language even larger, along with the fact that it wouldn't really buy you that much vs. what you can alread
by chromatic 15y ago
... macros would make what is already a fairly large language even larger, along with the fact that it wouldn't really buy you that much vs. what you can already do.
They would for me.
- jerf 15y agoYou sound like you have a specific use case in mind. I'm curious what that may be, and what kind of advantage you're expecting over already-existing constructs that could be used to do the same thing. (Unless you've really got a use case that simply can not be done with existing constructs, which I'd also be interested in.)
- chromatic 15y agoI 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.