Bizarre conventions

For some reason, return statements are outlawed in our shop. The official reason given is that you’d always need a place to “clean up things”, which is not guaranteed when you use return. Personally, I think that’s a bit far-fetched, but whatever.

However, to keep things a bit more readable, something called the “for-bool-loop” has been established. The ingenious snippet works like this:

for(bool bCond = true; bCond; bCond = false)
if(!success) {

I personally consider this to be, er, a bit bizarre. In most cases, returns would have been perfectly acceptable instead of this goto in disguise. I’m perfectly happy with returning or breaking (even goto) where it makes sense; but this thing seems somewhat gross.

Anyway, what’s your opinion on this?


One thought on “Bizarre conventions

  1. I thought that you’d say that. But this is about guard clauses, and I don’t think they work very vell as loop conditions (or you’d need multiple loops, which is a pain. And yes, you can have guard clauses without breaking the flow – which usually involves a bool and a number of ifs – but I hold that in that case, a return is both more natural and more readable.


Comments are closed.

Blog at

Up ↑

%d bloggers like this: