Tugger the SLUGger!SLUG Mailing List Archives

Re: [coders][NRS] 1st night

This one time, at band camp, Benno wrote:
>On Fri Jun 16, 2006 at 18:29:48 +1000, Erik de Castro Lopo wrote:
>>Yes it is, a concept borrowed from Perl. I even allows brain damage
>>    {
>>       # Huge chunk of code. 
>>    }
>>    unless condition
>Not trying to troll here, but what is exactly the point of it? It feels
>kinda intercal, lets change things around to confuse the programmer.
>I guess there are some cases where it is more natural to say (in english),
>"do something unless condition", than, "if not condition do something".
>Is that the rationale behind the language feature?

I've used it (post-conditionals) in Perl for some scripts that do Important
Things in the interest of making it more readable to future mes.

Depending on the context, of course:

  while (<WEBALIZER>) {
    if (! -t STDOUT) {
      next if (m/Truncating oversized \w+ field/);
      next if (m/Truncating oversized hostname/);
      next if (m/String exceeds storage size/);
      next if (m/No valid records found/);
      next if (m/Skipping oversized log record/);
      next if (m/Skipping bad record/);
    print $_;

basically skips printing a bunch of stuff; reordering that would have
increased the code size by at least double and I reckon would have made it
less clear what it did.

I wouldn't ever use it in the way Erik described though, clearly that's a
lose for readability.  Postconditional should only be used for one-liners.