X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=coroutines_and_aborts.mdwn;h=2ab7876322386980ad772e5dfbc2caadd1e1feae;hp=3d58e31e0880cb8e114afff6684f213522d39376;hb=7a822d410076318ea12be4e3cdb57e1b91218f42;hpb=85a09b7b528a52b6934654babaf809c8f69c6317 diff --git a/coroutines_and_aborts.mdwn b/coroutines_and_aborts.mdwn index 3d58e31e..2ab78763 100644 --- a/coroutines_and_aborts.mdwn +++ b/coroutines_and_aborts.mdwn @@ -358,7 +358,7 @@ How about this: Remind you of anything we discussed earlier? /Trivia. -Of course, it's possible to handle errors in other ways too. There's no reason why the implementation of `List.nth` *had* to raise an exception. They might instead have returned `Some a` when the list had an nth member `a`, and `None` when it does not. But it's pedagogically useful for us to think about this pattern now. +Of course, it's possible to handle errors in other ways too. There's no reason why the implementation of `List.nth` *had* to raise an exception. They might instead have returned `Some a` when the list had an nth member `a`, and `None` when it does not. But it's pedagogically useful for us to think about the exception-raising pattern now. When an exception is raised, it percolates up through the code that called it, until it finds a surrounding `try ... with ...` that matches it. That might not be the first `try ... with ...` that it encounters. For example: @@ -403,7 +403,7 @@ Many programming languages have this simplified exceution pattern, either instea if (x == 1) then value = 10 else - return 20 -- return early + return 20 -- abort early end return value + 100 -- in Lua, a function's normal value -- must always also be explicitly returned