Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Spoken Perl: and || && or what?by Zaxo (Archbishop) |
on Jul 29, 2001 at 13:17 UTC ( [id://100663]=perlmeditation: print w/replies, xml ) | Need Help?? |
I often use the logical operators && || and or as stand-ins for if (){};. Their short-circuit behavior is a handy idiom for conditionals. I sometimes struggle with how to pronounce them. I always say 'and' and 'or' to myself and I know what I mean. How can they be said to others? In English, 'do{} or die' is correctly understood by everyone. This extends to most ..or die; constructions in perl. The trouble is that it's the 'die' part that is recognised. The logical structure is swamped by the cliche. A m// && print; sequence is second nature to perl programmers. What do you say when you read it out loud to nonperlers? To sugarcoat plain "match and print", I've used:
When the predicate is just a flag, it's helpful to make it a gerund or noun ( $production || $debugging && print;), but what verbs make the meaning of that clear in spoken language? I wonder whether other languages provide more precision in these matters, too After Compline,
Back to
Meditations
|
|