gpt4 book ai didi

perl - 为什么 'last' 在 Perl 中被称为 'last' ?

转载 作者:行者123 更新时间:2023-12-03 01:39:41 26 4
gpt4 key购买 nike

在 Perl 中调用 last 而不是在 C 中调用 break 的历史原因是什么?

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
(来源:wired.com)

关于perl - 为什么 'last' 在 Perl 中被称为 'last' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1814447/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com