Re: Perl mnemonics
by BrowserUk (Patriarch) on Oct 07, 2008 at 14:53 UTC
|
| [reply] |
Re: Perl mnemonics
by moritz (Cardinal) on Oct 07, 2008 at 14:37 UTC
|
Well, perlvar has some mnemonics, which I found quite useful. | [reply] |
Re: Perl mnemonics
by TGI (Parson) on Oct 07, 2008 at 18:52 UTC
|
It isn't strictly perl, but it comes up doing graphics programming. When I need to remember the coordinate order for a box, I use "terrible" and "later babe" to remember whether the elements go in "top, right, bottom, left" or "left, top, right, bottom" order.
For example, CSS is terrible when you specify borders and margins:
margin: 1em 2em 3em 4em;
// is equivalent to:
margin-top: 1em;
margin-right: 2em;
margin-bottom: 3em;
margin-left: 4em;
| [reply] [d/l] |
|
Nice. In Cascading Style Sheets: The Definitive Guide, Eric Meyer uses 'TRouBLe' for that.
The same book also has 'LoVe, HA!' for the source order of common pseudo-classes (link, visited, hover, active).
email: perl -e 'print reverse map { chr( ord($_)-1 ) } split //, "\x0bufo/hojsfufqAofc";'
| [reply] |
|
I have to think of a clock to remember which order CSS properties go in.
The day starts at midnight, when the minute hand points up, or towards the top of the object. As the day progresses, the hand moves clockwise around, and points towards the right, then the bottom, then the left.
I spent quite a long time flipping through my CSS book when I needed to do something until I thought of that - I don't really work with CSS often enough that I could just memorize the order and know it without some help.
| [reply] |
|
"Terrible" stuck for me because I was having a terrible time remembering the order. And it was the first meaningful mapping I came up with.
I am in awe of your power of observation. I never noticed that the ordering went clockwise--a note in the docs somewhere to that effect would have saved me thousands of reference book pages flips and hundreds of google queries over the years.
| [reply] |
Re: Perl mnemonics
by zentara (Archbishop) on Oct 07, 2008 at 16:01 UTC
|
Like dragonchild, I go with the mental image.....one picture is worth a thousand words. I never was good at remembering poems, limericks, or jokes; but I can pull an image out of my memory easily. Also, If you are not actually cramming for a closed book test, why not just take a quick look at some code snippets (either in your personal snippet lib or search groups.google.com).However, there was one recently that I do use, regarding the packing rules in Gtk2, which I just can't seem to get straight without looking
at previous examples.
$vbox->pack_start ($widget, $expand, $fill, $padding);
it's the expand, fill, padding order that always gets me. So I remember
"extra fries please";
| [reply] [d/l] |
|
If I did Gtk2 programming, I'd probably call that order "WE FliP".
The pain of having to remember these orders is why any code I write that requires more than three arguments, gets modified to use named parameters. The downside is that you have to remember (and spell correctly) the parameter names, but that's what perldoc's for.
| [reply] |
|
| [reply] |
|
|
Re: Perl mnemonics
by dragonchild (Archbishop) on Oct 07, 2008 at 14:53 UTC
|
I don't remember things that way. Instead, my memory is akin to a photographic memory. I can't read off of the pages in my memory; instead, I have an index into what I've read. So, I know what things have been mentioned in docs, roughly where in the docs they are, etc.
Of course, this is nearly useless without access to perldoc.perl.org - in the past, I've mentioned that I can never remember the order of the args for splice. :-)
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
|
I'll be damned. I'm the same way. I remember where on the page of a book--e.g., right side, second paragraph, 1/3 into book--I saw something but rarely the page number. There must be a name for this.
| [reply] |
|
| [reply] |
|
Re: Perl mnemonics
by wfsp (Abbot) on Oct 07, 2008 at 15:35 UTC
|
The word always reminds me of a footnote in Programming Perl: "If you can't remember what a mnemonic is you're in trouble." :-)
| [reply] |
Re: Perl mnemonics
by JavaFan (Canon) on Oct 07, 2008 at 15:58 UTC
|
/m Multiple lines
/s Single line
/i case Insensitive (also grep -i)
/x eXtended pattern
/e Eval replacement
/p Preserve pre- and postmatch
/g Global matching
/c keep Current position
| [reply] [d/l] |