ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/common-sense/sense.pm
(Generate patch)

Comparing common-sense/sense.pm (file contents):
Revision 1.4 by root, Thu Jul 9 17:58:11 2009 UTC vs.
Revision 1.12 by root, Sat Aug 29 08:10:32 2009 UTC

20 20
21=over 4 21=over 4
22 22
23=item no warnings 23=item no warnings
24 24
25The dreaded warnings. Even worse, the horribly dreaded C<-w> switch. Even 25Ah, the dreaded warnings. Even worse, the horribly dreaded C<-w>
26though we don't care if other people use warnings (and certainly there are 26switch: Even though we don't care if other people use warnings (and
27useful ones), a lot of warnings simply go against the spirit of Perl, most 27certainly there are useful ones), a lot of warnings simply go against the
28spirit of Perl.
29
28prominently, the warnings related to C<undef>. There is nothing wrong with 30Most prominently, the warnings related to C<undef>. There is nothing wrong
29C<undef>: it has well-defined semantics, it is useful, and spitting out 31with C<undef>: it has well-defined semantics, it is useful, and spitting
30warnings you never asked for is just evil. 32out warnings you never asked for is just evil.
31 33
32So every module needs C<no warnings> to avoid somebody accidentally using 34So every module needs C<no warnings> to avoid somebody accidentally using
33C<-w> and forcing his bad standards on our code. No will do. 35C<-w> and forcing his bad standards on our code. No will do. Really, the
36C<-w> switch should only enable wanrings for the main program.
34 37
35Funnily enough, L<perllexwarn> explicitly mentions C<-w> (and not in a 38Funnily enough, L<perllexwarn> explicitly mentions C<-w> (and not in a
36favourable way), but standard utilities, such as L<prove>, or MakeMaker 39favourable way), but standard utilities, such as L<prove>, or MakeMaker
37when running C<make test> enable them blindly. 40when running C<make test> enable them blindly.
38 41
39=item use strict qw(subs vars) 42=item use strict qw(subs vars)
40 43
41Using C<use strict> is definitely common sense, but C<use strict 44Using C<use strict> is definitely common sense, but C<use strict
42'refs'> definitely overshoots it's usefulness. After almost two 45'refs'> definitely overshoots its usefulness. After almost two
43decades of Perl hacking, we decided that it does more harm than being 46decades of Perl hacking, we decided that it does more harm than being
44useful. Specifically, constructs like these: 47useful. Specifically, constructs like these:
45 48
46 @{ $var->[0] } 49 @{ $var->[0] }
47 50
49scope, and C<$var> can legally be C<undef>: 52scope, and C<$var> can legally be C<undef>:
50 53
51 @{ $var->[0] || [] } 54 @{ $var->[0] || [] }
52 55
53This is annoying, and doesn't shield against obvious mistakes such as 56This is annoying, and doesn't shield against obvious mistakes such as
54using C<"">, so one would even have to write: 57using C<"">, so one would even have to write (at least for the time
58being):
55 59
56 @{ defined $var->[0] ? $var->[0] : [] } 60 @{ defined $var->[0] ? $var->[0] : [] }
57 61
58... which nobody with a bit of common sense would consider 62... which nobody with a bit of common sense would consider
63writing.
64
59writing. Curiously enough, sometimes, perl is not so strict, as this works 65Curiously enough, sometimes perl is not so strict, as this works even with
60even with C<use strict> in scope: 66C<use strict> in scope:
61 67
62 for (@{ $var->[0] }) { ... 68 for (@{ $var->[0] }) { ...
63 69
64If that isnt hipocrasy! And all that from a mere program! 70If that isn't hipocrasy! And all that from a mere program!
65 71
66=item use feature qw(say state given) 72=item use feature qw(say state given)
67 73
68We found it annoying that we always have to enable extra features. If 74We found it annoying that we always have to enable extra features. If
69something breaks because it didn't anticipate future changes, so be 75something breaks because it didn't anticipate future changes, so be
70it. 5.10 broke almost all our XS modules and nobody cared either - and few 76it. 5.10 broke almost all our XS modules and nobody cared either (or at
77leats I know of nobody who really complained about gratitious changes - as
78opposed to bugs).
79
71modules that are no longer maintained work with newer versions of Perl, 80Few modules that are not actively maintained work with newer versions of
72regardless of use feature. 81Perl, regardless of use feature or not, so a new major perl release means
82changes to many modules - new keywords are just the tip of the iceberg.
73 83
74If your code isn't alive, it's dead, jim. 84If your code isn't alive, it's dead, jim - be an active maintainer.
75 85
76=item much less memory 86=item mucho reduced memory usage
77 87
78Just using all those pragmas together waste <blink>I<< B<776> kilobytes 88Just using all those pragmas mentioned in the SYNOPSIS together wastes
79>></blink> of precious memory in my perl, for I<every single perl process 89<blink>I<< B<776> kilobytes >></blink> of precious memory in my perl, for
80using our code>, which on our machines, is a lot. In comparison, this 90I<every single perl process using our code>, which on our machines, is a
81module only uses I<< B<four> >> kilobytes (I even had to write it out so 91lot. In comparison, this module only uses I<< B<four> >> kilobytes (I even
82it looks like more) of memory on the same platform. 92had to write it out so it looks like more) of memory on the same platform.
83 93
84The money/time/effort/electricity invested in these gigabytes (probably 94The money/time/effort/electricity invested in these gigabytes (probably
85petabytes globally!) of wasted memory could easily save 42 trees, and a 95petabytes globally!) of wasted memory could easily save 42 trees, and a
86kitten! 96kitten!
87 97
98Unfortunately, until everybods applies more common sense, there will still
99often be modules that pull in the monster pragmas. But one can hope...
100
88=cut 101=cut
89 102
90package common::sense; 103package common::sense;
91 104
92our $VERSION = '0.03'; 105our $VERSION = '1.0';
93 106
94sub import { 107sub import {
95 # no warnings 108 # no warnings
96 ${^WARNING_BITS} ^= ${^WARNING_BITS}; 109 ${^WARNING_BITS} ^= ${^WARNING_BITS};
97 110
106 119
1071; 1201;
108 121
109=back 122=back
110 123
111=head1 NO 'no common::sense' 124=head1 THERE IS NO 'no common::sense'!!!! !!!! !!
112 125
113This module doesn't offer an unimport. First of all, it wastes even more 126This module doesn't offer an unimport. First of all, it wastes even more
114memory, second, and more importantly, who with even a bit of common sense 127memory, second, and more importantly, who with even a bit of common sense
115would want no common sense? 128would want no common sense?
116 129
130=head1 STABILITY AND FUTURE VERSIONS
131
132Future versions might change just about everything in this module. We
133might test our modules and upload new ones working with newer versions of
134this module, and leave you standing in the rain because we didn't tell
135you.
136
137Most likely, we will pick a few useful warnings, instead of just disabling
138all of them. And maybe we will load some nifty modules that try to emulate
139C<say> or so with perls older than 5.10 (this module, of course, should
140work with older perl versions - supporting 5.8 for example is just common
141sense at this time. Maybe not in the future, but of course you can trust
142our common sense to be consistent with, uhm, our opinion).
143
144=head1 WHAT OTHER PEOPLE HAD TO SAY ABOUT THIS MODULE
145
146apeiron
147
148 "... wow"
149 "I hope common::sense is a joke."
150
151crab
152
153 "i wonder how it would be if joerg schilling wrote perl modules."
154
155H.Merijn Brand
156
157 "Just one more reason to drop JSON::XS from my distribution list"
158
159Pista Palo
160
161 "Something in short supply these days..."
162
163Steffen Schwigon
164
165 "This module is quite for sure *not* just a repetition of all the other
166 'use strict, use warnings'-approaches, and it's also not the opposite.
167 [...] And for its chosen middle-way it's also not the worst name ever.
168 And everything is documented."
169
170BKB
171
172 "[Deleted - thanks to Steffen Schwigon for pointing out this review was
173 in error.]"
174
175Somni
176
177 "the arrogance of the guy"
178 "I swear he tacked somenoe else's name onto the module
179 just so he could use the royal 'we' in the documentation"
180
181dngor
182
183 "Heh. '"<elmex at ta-sa.org>"' The quotes are semantic
184 distancing from that e-mail address."
185
186Jerad Pierce
187
188 "Awful name (not a proper pragma), and the SYNOPSIS doesn't tell you
189 anything either. Nor is it clear what features have to do with "common
190 sense" or discipline."
191
192acme
193
194 "THERE IS NO 'no common::sense'!!!! !!!! !!"
195
196apeiron (meta-comment)
197
198 How about quoting this: get a clue, you fucktarded amoeba.
199
117=head1 AUTHOR 200=head1 AUTHOR
118 201
119 Marc Lehmann <schmorp@schmorp.de> 202 Marc Lehmann <schmorp@schmorp.de>
120 http://home.schmorp.de/ 203 http://home.schmorp.de/
121 204
122 Robin Redeker, "<elmex at ta-sa.org>". 205 Robin Redeker, "<elmex at ta-sa.org>".
123 206
124
125=cut 207=cut
126 208

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines