为什么在Perl中最后一个叫’last’?

前端之家收集整理的这篇文章主要介绍了为什么在Perl中最后一个叫’last’?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
最后一个被称为Perl的历史原因是什么,而不是在C中被打破?

Perl的设计受到C(除了awk,sed和sh-下面的手册页)的影响之外,所以一定有一些推理背后不熟悉的C风格命名的break / last.

从Perl 1.000(1987年12月18日发布)手册页的一点历史:

[Perl] combines (in the author’s opinion,anyway) some of the best features of C,sed,awk,and sh,so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh,Pascal,and even BASIC|PLUS.)

解决方法

The semantics of ‘break’ or ‘last’ are
defined by the language (in this case
Perl),not by you.

Why not think of ‘last’ as “this is
the last statement to run for the
loop”.

It’s always struck me as odd that the
‘continue’ statement in ‘C’ starts the
next pass of a loop. This is
definitely a strange use of the
concept of “continue”. But it is the
semantics of ‘C’,so I accept it.

By trying to map particular
programming concepts into single
English words with existing meaning
there is always going to be some sort
of mismatching oddity

Source

另外,拉里·沃尔也有点奇怪.你看过他的照片吗?

Larry Wall http://www.wired.com/images/article/full/2007/12/larry_wall_250px.jpg

原文链接:https://www.f2er.com/Perl/172577.html

猜你在找的Perl相关文章