in reply to Re^5: next unless condition
in thread next unless condition

"With Perl, I'd say just write the most understandable and maintainable code you can." I definitely agree with that. Sometimes I see posts that use obscure and unnecessary language features that don't improve the efficiency of the code. Perl is a big language and not every thing that is possible should/needs to be used. The uncommon stuff should be used when it is really needed, not to impress some "new" monk. That is just the wrong way to teach Perl.

Yes, you are quite correct about load instructions. I've written ASM for Intel, DG, DEC, IBM, Motorola, SEL, Zilog and a few other very weird processors. I've even designed the hardware for 2 DSP processors myself. For those there was no ASM language, all code was what is called microcode. That is some hairy stuff to write because there is no O/S and it is possible to code instructions that can actually damage the processor (like say cause a conflict on a bus). If I remember right a load on a DG processor would set the flags, but that is not true on an Intel processor.

I think we both agree that using the Perl language features in a way that describes the algorithm clearly is the best way to go. I'm all for using the full power of the Perl language. I'm not saying that we shouldn't or that the code should be "dumbed down". I just object when the code is unnecessarily complicated. Sometimes it is necessary to be complicated.

We do have the problem where things that I think are simple, others think are complicated. I just wrote a piece of code with "DEBUG and print....", to me that is simple. I used the constant module, use constant DEBUG => 1;. The advantage of this over $DEBUG is supposed to be that Perl will eliminate the "and" if DEBUG => 0;

Replies are listed 'Best First'.
Re^7: next unless condition
by RonW (Parson) on Apr 04, 2016 at 23:55 UTC
    I used the constant module, use constant DEBUG => 1;. The advantage of this over $DEBUG is supposed to be that Perl will eliminate the "and" if DEBUG => 0;

    I'm pretty sure that DEBUG and will be optimized out when DEBUG is 0.

    Likewise, I'm pretty sure that if DEBUG would be optimized out when DEBUG is 0.

    I'm guessing it's the use constant DEBUG part that other people think is not simple.