My general rule for the postfix if is that it should only be used with
a single variable or constant (the code produced by postfix if is
slightly smaller and faster than compound).

So for the example you present I would use compound.

if ( $self->ide->{session_autosave} ) {
    $self->save_current_session;
}

But I would still allow postfix if for simple cases

$self->save_current_session if $something;
$self->save_current_session if DEBUG;

This approach also has the benefit that it can be encoded as a PPI
filter/Perl Critic rule fairly easily.

Adam K

On 17 July 2011 19:57, Gabor Szabo <szab...@gmail.com> wrote:
> I was just looking at Padre::Wx::Main::save_current_session and how it
> is used and found 4 use cases:
>
>
>  $self->ide->{session_autosave} and $self->save_current_session;
>
>
>  $self->save_current_session  if $self->ide->{session_autosave};
>
>  if ( $self->ide->{session_autosave} ) {
>      $self->save_current_session;
>  }
>
>  $self->ide->{session_autosave} and $self->save_current_session;
>
> So that's 3 different of saying the same.
>
> I wonder what do you think, should we start working toward
> a single style in Padre?
>
> Gabor
> _______________________________________________
> Padre-dev mailing list
> Padre-dev@perlide.org
> http://mail.perlide.org/mailman/listinfo/padre-dev
>
_______________________________________________
Padre-dev mailing list
Padre-dev@perlide.org
http://mail.perlide.org/mailman/listinfo/padre-dev

Reply via email to