加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 为什么在分号之前放置一个空格是不好的?

发布时间:2020-12-15 21:30:48 所属栏目:大数据 来源:网络整理
导读:perlstyle荚状态 No space before the semicolon 我看不出有什么理由.我知道在英文之前,不应该有两个字符之间的空格(如“?”,“;”,“
perlstyle荚状态

No space before the semicolon

我看不出有什么理由.我知道在英文之前,不应该有两个字符之间的空格(如“?”,“;”,“!”),但是我不明白为什么在编写Perl代码时应该是一个规则.

我承认我个人在分号前使用空格.我的理由是使声明更加清晰.我知道这不是一个很强的理由,但至少这是一个原因.

print "Somethingn with : some ; chars"; # good
print "Somethingn with : some ; chars" ; # bad??

第二个坏的原因是什么?

解决方法

从描述部分的第一段:

Each programmer will,of course,have his or her own preferences in regards to formatting,but there are some general guidelines that will make your programs easier to read,understand,and maintain.

并从描述部分的第三段:

Regarding aesthetics of code lay out,about the only thing Larry cares strongly about is that the closing curly bracket of a multi-line BLOCK should line up with the keyword that started the construct. Beyond that,he has other preferences that aren’t so strong:

Perl程序员的风格只是一个惯例.如果你不喜欢它,你可以选择忽略它.我会比较Sun’s Java Style guidelines或the suggestions for indenting in the K&R C book.有些环境有自己的指导.这些恰恰恰好是Perl的建议.

作为Jon Skeet said in a deleted answer这个问题:

If you’re happy to be inconsistent with what some other people like,then just write in the most readable form for you. If you’re likely to be sharing your code with others – and particularly if they’ll be contributing code too – then it’s worth trying to agree some consistent style.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读