TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

GOTO (Still) Considered Harmful

3 点作者 Baustin大约 11 年前

2 条评论

fexl大约 11 年前
A few days ago I wrote up something on this same issue:<p><a href="http://fexl.com/goto-considered-harmful" rel="nofollow">http:&#x2F;&#x2F;fexl.com&#x2F;goto-considered-harmful</a><p>However, after discussing the issue on the cryptography mailing list, I realized that the really serious problem here was not the use of goto itself, but the lack of an obvious test case.<p>Clearly Apple did not have a single test case which made the SSLVerifySignedServerKeyExchange function call sslRawVerify. Since the whole point is to call sslRawVerify, this is an astounding omission in testing.<p>The &quot;goto fail&quot; pattern is common throughout OpenSSL. I of course think OpenSSL stinks to high heaven, but for reasons not directly related to &quot;goto&quot;. I do think the use of &quot;goto&quot; gives off a bad &quot;code smell&quot; though.<p>I myself never use goto. When I&#x27;m writing code, I always create &quot;if&quot; or &quot;while&quot; blocks and then fill them in. It never even occurs to me to use goto.<p>My main objection to &quot;goto&quot;, aside from the spaghetti code which might arise from it, though not necessarily, is that goto makes it difficult to refactor code.<p>Normally it&#x27;s pretty easy to move a chunk of code into a separate function. However, if that code contains &quot;goto&quot;, then you&#x27;re pretty much stuck until you factor out the goto.
voidiac大约 11 年前
Goto is quite common among c-programmers when it comes to error handling.
评论 #7339900 未加载