people writing code like if foo: stuff1 if bar: stuff2 and not if not foo: return stuff if not bar: return stuff
-
Show this thread
-
-
-
Replying to @0xdeadbabe @f_borretti
a lot of people believe in single point of return i was really happy when the term "guard clauses" was invented, since it's impossible to defend any practice unless there's a trendy buzzword for it
2 replies 0 retweets 3 likes -
Replying to @chaosprime @f_borretti
single point of return is nonsense when you have to nest sixteen times to fuckery in order to achieve it
2 replies 0 retweets 10 likes -
people write the weirdest shit when they're being religious about what language features to reject - ever seen a C function with absurd nesting depth to clean up after error cases that could have been flat with gotos?
2 replies 0 retweets 6 likes -
Replying to @puellavulnerata @0xdeadbabe and
I've thought it over, and my final position on this is: single point of return, with gotos.
3 replies 0 retweets 1 like -
Replying to @0xDEBA5E12 @0xdeadbabe and
two points of return, a normal one and an error exit that does cleanup, and gotos is the pattern I keep ending up writing for the case I described
1 reply 1 retweet 1 like -
Replying to @puellavulnerata @0xDEBA5E12 and
i still don't understand what the tangible benefit of S.P.O.R. is
1 reply 0 retweets 0 likes -
Replying to @0xdeadbabe @0xDEBA5E12 and
me neither as a religious custom, but the two-return pattern is one I switch to as an alternative when the early-return one is producing noticeable amounts of duplicated cleanup code.
1 reply 0 retweets 3 likes
when single point of return does something important it's about making sure that everything that setup has happened for also gets teardown, 's more important in languages where you do a lot of managing of transient resources which everything ~modern~ is designed to avoid
-
-
Replying to @chaosprime @puellavulnerata and
a lot of the time single point of return advocacy is basically "hey guys i found the embedded systems dev"
1 reply 0 retweets 2 likes -
Replying to @chaosprime @puellavulnerata and
so yeah the two-point-of-return-with-cleanup pattern is addressing the core concern
0 replies 0 retweets 1 like
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.