Every so often we get a new or elder monk ask a question
of the "Hey Doc, it hurts when I do this." nature. Often,
the immediate response is "Stop doing that," in accordance
with the old old joke.
I would like to encourage you all to put aside your
blinders on these questions and look a little closer at
what the pathological behavior often winds up teaching us.
Today the winner is :eval + no warnings = no memory. I wish I had marked some
of the past ones that amused me since they taught me
important things.
The issue here is, when you stress something past it's
intended limits, you often learn more than what the limit
is, you learn why the limit is or that a huge bug exists. =)
I've soaked up a lot of interesting data about Perl the
language and perl the executable and the systems that perl
runs on thanks to the pathological edge-walkers and push-to-the-limit-types.
- I know that the parser optimises away constants that
are concatenated together. Thus, $s="my".' friends';
inside a loop is no slower than $s='my friends';
- I know that if (0) {}; poofs away in the
parser as well.
- I know that order of execution isn't guaranteed in a
math expression. Thus $x = $y++/--$y; is evil since
you have no idea which side of the '/' perl will do first.
- I know most OSes only allow a program about 256 open
handles. So after the three on unix that you start with
already opened, you hit a nasty wall after opening 127 pipes
to yourself or 254 files for reading and writing at once.
- We now know that 'no' leaks memory and that it seems
worse in 5.6.0
There are a million of these oddities floating around
in any language and many of them are indistinguishable from
features. They are the difference between knowing what
works and why something broke. Sure we should be suspicious
of people doing mad things but the mad people find all the
good bugs these days. A few times a year, somebody posts
a bit of code to the perl5porters that everyone knows is
evil and wrong and sure to break only to discover that
no two of them agree on where it breaks. Or worse, that it broke
something so unexpected that they all just have to
sit back and whistle.
In any case, I'm not asking much, just look a little
closer at the weird and wacky. There is more there to learn
than you think.
Update: go see one-liner hogs for some serious one-liner pathology. =)
--
$you = new YOU;
honk() if $you->love(perl)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.