Condition style is always available as an option. But in the types of situations you're describing, where you actually want to end the execution early, you end up using condition style because abort style does not exist. That's the case with array.forEach, and it's one of the reasons array.some was added.
But your server middleware example is more complicated I think. Not only are we talking about an asynchronous environment, it's also not clear what the "abort" step is because this is presumably a server middleware chain. Each middleware isn't aware of those around it. It just calls next. You're assuming the middleware knows enough to decide the request can't be fulfilled, in which case it needs to "finish". Whatever that means. Instead, you could consider that all the middle needs to do is tell you if it succeeded or failed. And your middleware framework could have some kind of branching strategy. Does "finish" complete the request early? Does it skip just the next middleware? Does it start a completely different middleware chain? I don't know, but it may not be a good pattern to start adding ad hoc exceptions into what should be a predictable middleware harness. Sorry, I may be over thinking your problem here. But I'm interested because this is something I've thought about for geddy as well. I'd be curious to know more about an example situation where you run into this issue. :Marco On Monday, January 7, 2013 8:39:36 AM UTC-8, Bradley Meck wrote: > > This is good, gets me thinking. This brings up that there are 2 styles of > approaching this issue: > > abort style - manually cause the action to fast fail > condition style - provide a condition to check on every step of the action > > May help others thinking about this as well to think of both perspectives, > personally I prefer abort style when available to > avoid unnecessary condition checks. But condition checks can be reduced to > a boolean, so that may be a suitable solution still. > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
