News for hackers. Stuff that matters.
Re:Early exit is a tail call optimization of procedural lang... by phamilton on Friday December 18, 2015 @03:21AM (#10757354)
I come from an FP background, and so I tend to avoid multiple assignment as well. In such a scenario, there's a single line that assigns rv. Each of the variables used in assigning rv are each assigned just once. I can follow the graph fairly easily until I get to the bit I need. Often its something like "what conversion rate for currency are we using?" and following that chain gets me there quickly.
Re:Early exit is a tail call optimization of procedural lang... by camgunz on Sunday December 20, 2015 @12:33AM (#10766176)
Yeah, I can definitely see how if you're disciplined it can be effective. But in my case, I've seen integer return values hold status codes from multiple modules and libraries, file handles, and enum values all in the same function just to twist everything together so that no matter where it stops executing, "rv" has some kind of value so that the ending "return rv" won't just return success. It was total madness, and it's really hard to do anything as complicated and fragile as that with early returns.

I will admit though that no programming style will sufficiently protect against bad coding :). I'm sure even if this person did everything I advised, they'd still find a way to overcomplicate and confuse things. So maybe the issue is moot, or at least bigger than style.