Hacker News new | past | comments | ask | show | jobs | submit login

> I don't quite see try/except/finally as a goto, since I'm not sure how to make one that behaves that way.

I suggested try/except because goto is very commonly used to provide similar behaviour in C where there are no exceptions.

> break/continue etc. should be discouraged for that precise reason ... the best 'rigorous' model of programs is maintaining pre and post conditions ... Obviously if actual Monads are an option they should be preferred.

But why? Do you have any evidence that this leads to better/more robust/easier to understand code in practice?




Does personal experience count? (note also that I indicated that ultimately all of this is just my opinion). Personally I find I mostly end up creating bugs when I don't have a clear enough image of what the proper pre-condition to a loop should be and what its post-condition should be. I therefore believe that code that by its very structure can't easily be assigned pre/post conditions would make things quite difficult. Post-conditions also tend to make it easier to reason that the code is correct (provided they are documented).

As for the Monad quote, well it's use is somewhat limited in Python, however returning a 'trivial' result rather than an exception usually ends up being easier to work with. Which is appropriate varies though, and in Python there's not much reason to avoid exceptions for performance reasons anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: