goto有害论

更新时间:2023-07-05 20:40:34 阅读: 评论:0

goto有害论.txt世上最珍贵的不是永远得不到或已经得到的,而是你已经得到并且随时都有
可能失去的东西!爱情是灯,友情是影子。灯灭时,你会发现周围都是影子。朋友,是在最
后可以给你力量的人。Go To Statement Considered Harmful                Page 1 of 3
Go To Statement Considered Harmful
Edsger W. Dijkstra
Reprinted from Communications of the ACM, Vol. 11, No. 3, March 1968, pp. 147-148.
Copyright
1968, Association for Computing Machinery, Inc.
This is a digitized copy derived from an ACM copyrighted work. It is not guaranteed
to be an accurate
copy of the author's original work.
Key Words and Phras:
go to statement, jump instruction, branch instruction, conditional clau,
alternative clau,
repetitive clau, program intelligibility, program quencing
CR Categories:
4.22, 6.23,
5.24
Editor:
For a number of years I have been familiar with the obrvation that the quality of
programmers is a
decreasing function of the density of go to statements in the programs they produce.
More recently I
discovered why the u of the go to statement has such disastrous effects, and I became
convinced that
the go to statement should be abolished from all "higher level" programming languages
(i.e. everything
except, perhaps, plain machine code). At that time I did not attach too much importance
to this
discovery; I now submit my considerations for publication becau in very recent
discussions in which
the subject turned up, I have been urged to do so.
My first remark is that, although the programmer's activity ends when he has
constructed a correct
program, the process taking place under control of his program is the true subject
matter of his activity,
for it is this process that has to accomplish the desired effect; it is this process
什么如柴that in its dynamic
behavior has to satisfy the desired specifications. Yet, once the program has been
made, the "making' of
the corresponding process is delegated to the machine.
My cond remark is that our intellectual powers are rather geared to master static
relations and that our
powers to visualize process evolving in time are relatively poorly developed. For
that reason we
should do (as wi programmers aware of our limitations) our utmost to shorten the
conceptual gap
between the static program and the dynamic process, to make the correspondence between
the program
(spread out in text space) and the process (spread out in time) as trivial as possible.
www.acm/classics/oct95/                                                              9/26/2002
Go To Statement Considered Harmful                Page 2 of 3
Let us now consider how we can characterize the progress of a process. (You may think
about this
question in a very concrete manner: suppo that a process, considered as a time
succession of actions, is
stopped after an arbitrary action, what data do we have to fix in order that we can
redo the process until
the very same point?) If the program text is a pure concatenation of, say, assignment
statements (for the
purpo of this discussion regarded as the descriptions of single actions) it is
sufficient to point in the旧诗
program text to a point between two successive action descriptions. (In the abnce
of go to statements I
can permit mylf the syntactic ambiguity in the last three words of the previous
ntence: if we par
them as "successive (action descriptions)" we mean successive in text space; if we
par as "(successive
action) descriptions" we mean successive in time.) Let us call such a pointer to a
suitable place in the
text a "textual index."
When we include conditional claus (if B then A), alternative claus (if B then
A1 el A2), choice
claus as introduced by C. A. R. Hoare (ca[i] of (A1, A2,, An)),or conditional
expressions as
introduced by J. McCarthy (B1 -> E1, B2 -> E2, , Bn -> En), the fact remains that
the progress of the
process remains characterized by a single textual index.
As soon as we include in our language procedures we must admit that a single textual
我爱雪莲花index is no longer
sufficient. In the ca that a textual index points to the interior of a procedure
body the dynamic progress
is only characterized when we also give to which call of the procedure we refer. With
the inclusion of
procedures we can characterize the progress of the process via a quence of textual
indices, the length
张謇纪念馆of this quence being equal to the dynamic depth of procedure calling.
Let us now consider repetition claus (like, while B repeat A or repeat A until B). Logically speaking,
such claus are now superfluous, becau we can express repetition with the aid of recursive
procedures. For reasons of realism I don't wish to exclude them: on the one hand, repetition claus can
be implemented quite comfortably with prent day finite equipment; on the other hand, the reasoning
肠道功能紊乱pattern known as "induction" makes us well equipped to retain our intellectual grasp on the process
generated by repetition claus. With the inclusion of the repetition claus textual indices are no longer
sufficient to describe the dynamic progress of the process. With each entry into a repetition clau,
however, we can associate a so-called "dynamic index," inexorably counting the ordinal number of the
corresponding current repetition. As repetition claus (just as procedure calls) may be applied nestedly,
we find that now the progress of the process can always be uniquely characterized by a (mixed)
喝酒发朋友圈文案quence of textual and/or dynamic indices.
The main point is that the values of the indices are outside programmer's control; they are generated
科研项目管理
(either by the write-up of his program or by the dynamic evolution of the process) whether he wishes or
not. They provide independent coordinates in which to describe the progress of the process.
Why do we need such independent coordinates? The reason is - and this ems to be inherent to
quential process - that we can interpret the value of a variable only with respect to the progress of
the process. If we wish to count the number, n say, of people in an initially empty room, we can achieve
this by increasing n by one whenever we e someone entering the room. In the in-between moment that
we have obrved someone entering the room but have not yet performed the subquent increa of n,
its value equals the number of people in the room minus one!
The unbridled u of the go to statement has an immediate conquence that it becomes terribly hard to
find a meaningful t of coordinates in which to describe the process progress.
Usually, people take into
account as well the values of some well chon variables, but this is out of the
question becau it is
relative to the progress that the meaning of the values is to be understood! With
the go to statement
one can, of cour, still describe the progress uniquely by a counter counting the
number of actions
什么的小虾performed since program start (viz. a kind of normalized clock). The difficulty is
that such a coordinate,
www.acm/classics/oct95/                                                              9/26/2002

本文发布于:2023-07-05 20:40:34,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1080484.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:影子   爱情   失去   东西
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图