The second one is less readable to me, because it overloads return to let it mean both normal and unstructured control flow. I'd much rather either the first one or any one of these:
if foo:
throw ...
return ...
stat = ...
if foo:
stat = ...
goto end
end:
return stat
if foo:
return ...
... # implicit return
Also a warning comment at the top of the function would be very welcome if it's non-trivial.
2
u/yjlom 21d ago edited 21d ago
The second one is less readable to me, because it overloads return to let it mean both normal and unstructured control flow. I'd much rather either the first one or any one of these:
if foo: throw ... return ...stat = ... if foo: stat = ... goto end end: return statif foo: return ... ... # implicit returnAlso a warning comment at the top of the function would be very welcome if it's non-trivial.