<div dir="ltr">A problem with the "list of expensive functions" style is that not everything we want to do will necessarily be a pure function. I.e. if it is, this is great:<div><br></div><div>fs = [expensive_1, expensive_2, expensive_3]</div>
<div>for f in fs:</div><div> x = f(known, args, here)</div><div> if x:</div><div> break</div><div><br></div><div>But sometimes you want more general expressions that might be expensive. Nonetheless, using while/break gets us the early exit just as well:</div>
<div><br></div><div>while True:</div><div> x = expensive_1() + 1</div><div> if x: break</div><div> x = expensive_2() // 2</div><div> if x: break</div><div> x = expensive_3() % 3</div><div> if x: break</div>
<div> x = default_value</div><div> break</div><div><br></div><div>Honestly that isn't very verbose. And also, while the def/return approach is similar, it *does* require passing in all the relevant lexical elements needed into the function (well, or using a closure), and that's a bit more bookkeeping possibly.<br>
<div class="gmail_extra"><br><br><br clear="all"><div><br></div>-- <br>Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>
advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br>
</div></div></div>