in reply to Re: No braces
in thread No braces

For me, the irritating part about reading code with "if" qualifiers at the end is the sense of letdown I get from figuring out the first part of the line only to see that it might not fire because of the "if". However,

do_something() if COND;

buys me both that initial visual cue that the statement is qualified as well as the satisfaction of the simpler, less "noisy", flavor of "if".

Replies are listed 'Best First'.
Re: Re: Re: No braces
by demerphq (Chancellor) on Feb 11, 2004 at 19:25 UTC

    Which part is more important? The conditional or the statement? In some cases its one, some cases the other. And if you really want the conditional in front then just write:

    ($CONDITION) && do_something();

    But usually you are more interested in what might happen than exactly why so that becomes

    do_something() unless $exception;

    But sometime the conditional part really aught to go first:

    open ... or die ....

    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi