转到语句是有害的? [英] Go To Statement Considered Harmful?

查看:150
本文介绍了转到语句是有害的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果上述说法是正确的,那么为什么当我使用反射镜上的.NET基础类库我看到它使用了很多

If the statement above is correct, then why when I use reflector on .Net BCL I see it is used a lot?

编辑:让我改一下:是?所有的GO-TO是我在人类或编译器编写的反射看到

let me rephrase: are all the GO-TO's I see in reflector written by humans or compilers?

推荐答案

以上是不是真的正确的 - 这是通过Dijkstra算法使用的论战设备一次的goto的时候大约在使用的唯一的流量控制结构。事实上,一些人产生了反驳,包括Knuth的经典的结构化编程使用GOTO纸(从内存标题)。还有一些情况下(错误处理,状态机),其中的goto可以产生更清晰的代码(恕我直言),比结构化的替代品。

The above isn't really correct - it was a polemical device used by Dijkstra at a time when gotos were about the only flow control structure in use. In fact, several people have produced rebuttals, including Knuth's classic "Structured Programming Using Goto" paper (title from memory). And there are some situations (error handling, state machines) where gotos can produce clearer code (IMHO), than the "structured" alternatives.

这篇关于转到语句是有害的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆