… | |
… | |
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 |
… | |
… | |
41 | |
41 | |
42 | This is annoying, and doesn't shield against obvious mistakes such as |
42 | This is annoying, and doesn't shield against obvious mistakes such as |
43 | using C<"">, so one would even have to write (at least for the time |
43 | using C<"">, so one would even have to write (at least for the time |
44 | being): |
44 | being): |
45 | |
45 | |
46 | @{ defined $var->[0] ? $var->[0] : [] } |
46 | @{ defined $var->[0] ? $var->[0] : [] } |
47 | |
47 | |
48 | ... which nobody with a bit of common sense would consider |
48 | ... which nobody with a bit of common sense would consider |
49 | writing. |
49 | writing: clear code is clearly something else. |
50 | |
50 | |
51 | Curiously enough, sometimes perl is not so strict, as this works even with |
51 | Curiously enough, sometimes perl is not so strict, as this works even with |
52 | C<use strict> in scope: |
52 | C<use strict> in scope: |
53 | |
53 | |
54 | for (@{ $var->[0] }) { ... |
54 | for (@{ $var->[0] }) { ... |
… | |
… | |
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 | quanth |
|
|
257 | |
|
|
258 | common sense is beautiful, json::xs is fast, Anyevent, EV are fast and |
|
|
259 | furious. I love mlehmannware ;) |
|
|
260 | |
|
|
261 | =head1 FREQUQNTLY ASKED QUESTIONS |
|
|
262 | |
|
|
263 | Or frequently-come-up confusions. |
|
|
264 | |
|
|
265 | =over 4 |
|
|
266 | |
|
|
267 | =item Is this module meant to be serious? |
|
|
268 | |
|
|
269 | Yes, we would have put it under the C<Acme::> namespace otherwise. |
|
|
270 | |
|
|
271 | =item But the manpage is written in a funny/stupid/... way? |
|
|
272 | |
|
|
273 | This was meant to make it clear that our common sense is a subjective |
|
|
274 | thing and other people can use their own notions, taking the steam out |
|
|
275 | of anybody who might be offended (as some people are always offended no |
|
|
276 | matter what you do). |
|
|
277 | |
|
|
278 | This was a failure. |
|
|
279 | |
|
|
280 | But we hope the manpage still is somewhat entertaining even though it |
|
|
281 | explains boring rationale. |
|
|
282 | |
|
|
283 | =item Why do you impose your conventions on my code? |
|
|
284 | |
|
|
285 | For some reason people keep thinking that C<common::sense> imposes |
|
|
286 | process-wide limits, even though the SYNOPSIS makes it clear that it works |
|
|
287 | like other similar modules - only on the scope that uses them. |
|
|
288 | |
|
|
289 | So, no, we don't - nobody is forced to use this module, and using a module |
|
|
290 | that relies on common::sense does not impose anything on you. |
|
|
291 | |
|
|
292 | =item Why do you think only your notion of common::sense is valid? |
|
|
293 | |
|
|
294 | Well, we don't, and have clearly written this in the documentation to |
|
|
295 | every single release. We were just faster than anybody else w.r.t. to |
|
|
296 | grabbing the namespace. |
|
|
297 | |
|
|
298 | =item But everybody knows that you have to use strict and use warnings, |
|
|
299 | why do you disable them? |
|
|
300 | |
|
|
301 | Well, we don't do this either - we selectively disagree with the |
|
|
302 | usefulness of some warnings over others. This module is aimed at |
|
|
303 | experienced Perl programmers, not people migrating from other languages |
|
|
304 | who might be surprised about stuff such as C<undef>. |
|
|
305 | |
|
|
306 | In fact, this module is considerably I<more> strict than the canonical |
|
|
307 | C<use strict; use warnings>, as it makes all warnings fatal in nature, so |
|
|
308 | you can get away with as many things as with the canonical approach. |
|
|
309 | |
|
|
310 | This was not implemented in version 1.0 because of the daunting number |
|
|
311 | of warning categories and the difficulty in getting exactly the set of |
|
|
312 | warnings you wish (i.e. look at the SYNOPSIS in how complicated it is to |
|
|
313 | get a specific set of warnings - it is not reasonable to put this into |
|
|
314 | every module, the maintainance effort would be enourmous). |
|
|
315 | |
|
|
316 | =item But many modules C<use strict> or C<use warnings>, so the memory |
|
|
317 | savings do not apply? |
|
|
318 | |
|
|
319 | I am suddenly so sad. |
|
|
320 | |
|
|
321 | But yes, that's true. Fortunately C<common::sense> still uses only a |
|
|
322 | miniscule amount of RAM. |
|
|
323 | |
|
|
324 | =item But it adds another dependency to your modules! |
|
|
325 | |
|
|
326 | It's a fact, yeah. But it's trivial to install, most popular modules have |
|
|
327 | many more dependencies and we consider dependencies a good thing - it |
|
|
328 | leads to better APIs, more thought about interworking of modules and so |
|
|
329 | on. |
|
|
330 | |
|
|
331 | =item But! But! |
|
|
332 | |
|
|
333 | Yeah, we know. |
|
|
334 | |
|
|
335 | =back |
|
|
336 | |
256 | =head1 AUTHOR |
337 | =head1 AUTHOR |
257 | |
338 | |
258 | Marc Lehmann <schmorp@schmorp.de> |
339 | Marc Lehmann <schmorp@schmorp.de> |
259 | http://home.schmorp.de/ |
340 | http://home.schmorp.de/ |
260 | |
341 | |