Ut oh, someone has decided to claim "if considered harmful". Be afraid, be very afraid. I once had a room mate (many years ago) whose professor had told them NEVER to use an if, only the trinary, and to make all functions 3 lines long. If he's trying to teach functional programming, I can kind of see the point .. but this was a (dare I say the name) Java (there I said it) class.
Point here is if has VALUE ... dispatch tables are an awesome trick, and I'm glad you have discovered them, but sometimes the blocks of code are incredibly unlike, or the tests don't (yes really) map down to scalars.
What you should have said was "sometimes dispatch tables are better than if", not "friends don't let friends use if". That, my friend, is the "if something is good, more of something must be better" fallacy. Much like what happened to the XP crowd... Dispatch tables and FP are good. Nested ifs can usually be a sign problem, but mapping ifs to hashes just makes hashes of virtual ifs...
Anyhow, closures rock. Use them. In many cases, not using an if is a gateway to a higher plane of existance (as is passing functions around), but don't be afraid of if.
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.