… | |
… | |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use common::sense; |
7 | use common::sense; |
8 | |
8 | |
9 | # roughly the same as, with much lower memory usage: |
9 | # supposed to be the same, with much lower memory usage, as: |
10 | # |
10 | # |
11 | # use strict qw(vars subs); |
11 | # use strict qw(vars subs); |
12 | # use feature qw(say state switch); |
12 | # use feature qw(say state switch); |
13 | # no warnings; |
13 | # no warnings; |
14 | # use warnings qw(FATAL closed threads internal debugging pack substr malloc |
14 | # use warnings qw(FATAL closed threads internal debugging pack substr malloc |
… | |
… | |
139 | |
139 | |
140 | =cut |
140 | =cut |
141 | |
141 | |
142 | package common::sense; |
142 | package common::sense; |
143 | |
143 | |
144 | our $VERSION = '2.0'; |
144 | our $VERSION = '2.01'; |
145 | |
145 | |
146 | # paste this into pelr to find bitmask |
146 | # paste this into perl to find bitmask |
147 | |
147 | |
148 | # no warnings; |
148 | # no warnings; |
149 | # use warnings qw(FATAL closed threads internal debugging pack substr malloc unopened portable prototype |
149 | # use warnings qw(FATAL closed threads internal debugging pack substr malloc unopened portable prototype |
150 | # inplace io pipe unpack regexp deprecated exiting glob digit printf |
150 | # inplace io pipe unpack regexp deprecated exiting glob digit printf |
151 | # utf8 layer reserved parenthesis taint closure semicolon); |
151 | # utf8 layer reserved parenthesis taint closure semicolon); |
… | |
… | |
154 | |
154 | |
155 | # overload should be included |
155 | # overload should be included |
156 | |
156 | |
157 | sub import { |
157 | sub import { |
158 | # verified with perl 5.8.0, 5.10.0 |
158 | # verified with perl 5.8.0, 5.10.0 |
159 | ${^WARNING_BITS} = "\xfc\x3f\xf3\x00\x0f\xf3\xcf\xc0\xf3\xfc\x33\x03"; |
159 | ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "\xfc\x3f\xf3\x00\x0f\xf3\xcf\xc0\xf3\xfc\x33\x03"; |
160 | |
160 | |
161 | # use strict vars subs |
161 | # use strict vars subs |
162 | $^H |= 0x00000600; |
162 | $^H |= 0x00000600; |
163 | |
163 | |
164 | # use feature |
164 | # use feature |
… | |
… | |
251 | |
251 | |
252 | apeiron (meta-comment about us commenting^Wquoting his comment) |
252 | apeiron (meta-comment about us commenting^Wquoting his comment) |
253 | |
253 | |
254 | How about quoting this: get a clue, you fucktarded amoeba. |
254 | How about quoting this: get a clue, you fucktarded amoeba. |
255 | |
255 | |
|
|
256 | =head1 FREQUQNTLY ASKED QUESTIONS |
|
|
257 | |
|
|
258 | Or frequently-come-up confusions. |
|
|
259 | |
|
|
260 | =over 4 |
|
|
261 | |
|
|
262 | =item Is this module meant to be serious? |
|
|
263 | |
|
|
264 | Yes, we would have put it under the C<Acme::> namespace otherwise. |
|
|
265 | |
|
|
266 | =item But the manpage is written in a funny/stupid/... way? |
|
|
267 | |
|
|
268 | This was meant to make it clear that our common sense is a subjective |
|
|
269 | thing and other people can use their own notions, taking the steam out |
|
|
270 | of anybody who might be offended (as some people are always offended no |
|
|
271 | matter what you do). |
|
|
272 | |
|
|
273 | This was a failure. |
|
|
274 | |
|
|
275 | But we hope the manpage still is somewhat entertaining even though it |
|
|
276 | explains boring rationale. |
|
|
277 | |
|
|
278 | =item Why do you impose your conventions on my code? |
|
|
279 | |
|
|
280 | For some reason people keep thinking that C<common::sense> imposes |
|
|
281 | process-wide limits, even though the SYNOPSIS makes it clear that it works |
|
|
282 | like other similar modules - only on the scope that uses them. |
|
|
283 | |
|
|
284 | So, no, we don't - nobody is forced to use this module, and using a module |
|
|
285 | that relies on common::sense does not impose anything on you. |
|
|
286 | |
|
|
287 | =item Why do you think only your notion of common::sense is valid? |
|
|
288 | |
|
|
289 | Well, we don't, and have clearly written this in the documentation to |
|
|
290 | every single release. We were just faster than anybody else w.r.t. to |
|
|
291 | grabbing the namespace. |
|
|
292 | |
|
|
293 | =item But everybody knows that you have to use strict and use warnings, |
|
|
294 | why do you disable them? |
|
|
295 | |
|
|
296 | Well, we don't do this either - we selectively disagree with the |
|
|
297 | usefulness of some warnings over others. This module is aimed at |
|
|
298 | experienced Perl programmers, not people migrating from other languages |
|
|
299 | who might be surprised about stuff such as C<undef>. |
|
|
300 | |
|
|
301 | In fact, this module is considerably I<more> strict than the canonical |
|
|
302 | C<use strict; use warnings>, as it makes all warnings fatal in nature, so |
|
|
303 | you can get away with as many things as with the canonical approach. |
|
|
304 | |
|
|
305 | This was not implemented in version 1.0 because of the daunting number |
|
|
306 | of warning categories and the difficulty in getting exactly the set of |
|
|
307 | warnings you wish (i.e. look at the SYNOPSIS in how complicated it is to |
|
|
308 | get a specific set of warnings - it is not reasonable to put this into |
|
|
309 | every module, the maintainance effort would be enourmous). |
|
|
310 | |
|
|
311 | =item But many modules C<use strict> or C<use warnings>, so the memory |
|
|
312 | savings do not apply? |
|
|
313 | |
|
|
314 | I am suddenly so sad. |
|
|
315 | |
|
|
316 | But yes, that's true. Fortunately C<common::sense> still uses only a |
|
|
317 | miniscule amount of RAM. |
|
|
318 | |
|
|
319 | =item But it adds another dependency to your modules! |
|
|
320 | |
|
|
321 | It's a fact, yeah. But it's trivial to install, most popular modules have |
|
|
322 | many more dependencies and we consider dependencies a good thing - it |
|
|
323 | leads to better APIs, more thought about interworking of modules and so |
|
|
324 | on. |
|
|
325 | |
|
|
326 | =item But! But! |
|
|
327 | |
|
|
328 | Yeah, we know. |
|
|
329 | |
|
|
330 | =back |
|
|
331 | |
256 | =head1 AUTHOR |
332 | =head1 AUTHOR |
257 | |
333 | |
258 | Marc Lehmann <schmorp@schmorp.de> |
334 | Marc Lehmann <schmorp@schmorp.de> |
259 | http://home.schmorp.de/ |
335 | http://home.schmorp.de/ |
260 | |
336 | |