Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I certainly don't agree with replacing "if else" with "? :". You throw your readability out the window, IMO. But I guess that is what makes it "extreme".
    • Each has it's use in it's place. Use "? :" when you need to return a value in a statement inline. E.g.,
      my $x = $test ? $y : $z;
      # is better (disclaimer - IMHO) than:
      my $x;
      if ($test) {
        $x = $y;
      } else {
        $x = $z;
      All of the examples of "? :" in that document (that I can see) are similar to this, so they're ok. Using "? :" in a void context is arguably not so good.
      • my $x = $test ? $y : $z;

        I can understand doing the above becuase visually you can isolate that line and grok it quickly. When you use it in a larger "else if" context you loose that visual recognition.

        • by pudge (1) on 2004.04.20 16:58 (#30238) Homepage Journal
          Like this?
              my $mode = (ref $hash->{CALLBACK} eq 'CODE'
                  ? kAEQueueReply
                  : (exists $hash->{REPLY}    # check event setting
                      ? $hash->{REPLY}
                      : exists $self->{REPLY}    # check global setting
                          ? $self->{REPLY}
                          : 1        # default to wait
                      ? kAEWaitReply
                      : kAENoReply)
                  | (exists $hash->{MODE}
                      ? $hash->{MODE}
                      : exists $self->{MODE}
                          ? $self->{MODE}
                          : (kAECanInteract | kAECanSwitchLayer));
          Sorry. :-)