1
0
mirror of https://github.com/golang/go synced 2024-11-21 14:24:44 -07:00

Language FAQ: editing tweaks after iant.

R=iant
CC=golang-dev
https://golang.org/cl/874043
This commit is contained in:
Rob Pike 2010-04-07 16:13:14 -07:00
parent 956926ee31
commit a3db32d2a6

View File

@ -282,14 +282,14 @@ This remains an open issue.
<h3 id="exceptions"> <h3 id="exceptions">
Why does Go not have exceptions?</h3> Why does Go not have exceptions?</h3>
<p> <p>
We believe that coupling the usual idea of exceptions to a control We believe that coupling exceptions to a control
structure, as in the <code>try-catch-finally</code> idiom, results in structure, as in the <code>try-catch-finally</code> idiom, results in
convoluted code. It also tends to encourage programmers to label convoluted code. It also tends to encourage programmers to label
too many ordinary errors, such as failing to open a file, as too many ordinary errors, such as failing to open a file, as
exceptional. And then the type system gets mixed in. exceptional.
</p> </p>
<p> <p>
Go takes a different approach. Instead of exceptions, it has couple Go takes a different approach. Instead of exceptions, it has a couple
of built-in functions to signal and recover from truly exceptional of built-in functions to signal and recover from truly exceptional
conditions. The recovery mechanism is executed only as part of a conditions. The recovery mechanism is executed only as part of a
function's state being torn down after an error, which is sufficient function's state being torn down after an error, which is sufficient