Should I use common::sense or just stick with `use strict` and `use warnings`?

后端 未结 9 1078
自闭症患者
自闭症患者 2021-01-08 00:37

I recently installed a module from CPAN and noticed one of its dependencies was common::sense, a module that offers to enable all the warnings you want, and none that you do

9条回答
  •  佛祖请我去吃肉
    2021-01-08 00:59

    Many of peoples argues in a comments with what if the MP changes, it will break your code. While this can be an real threat, here is already MUCH things what are changes over time and break the code (sometimes after a deprecation cycle, sometimes not...).

    Some other modules changed the API, so breaks things, and nobody care about them. E.g. Moose has at least two things what are deprecated now, and probably will be forbidden in some future releases.

    Another example, years ago was allowed to write

    for $i qw(some words)
    

    now, it is deprecated. And many others... And this is a CORE language syntax.

    Everybody survived. So, don't really understand why many of people argues againist helper modules. When they going to change, (probably) here will be a sort of deprecation cycle... So, my view is:

    • if you write programs to yourself, use any module you want ;)
    • if you write a program to someone, where someone others going to maintnanece it, use minimal nonstandard "pragma-like" modules (common::sense, modern::perl, uni::perl etc...)
    • in the stackoverflow questions, you can safely use common::sense or Modern::Perl etc. - most of users who will answer, your questions, knows them. Everybody understand than it is easier to write use 5.010; for enable strict, warnings and fearures with 10 chars as with 3 lines...

提交回复
热议问题