Palit, Nilanjan wrote:
        - Basic questions on boolean expressions & operator precedence
like, why does 'open(...) or die "..."' work? (and similar questions
posed by Greg)

That seems perfectly reasonable to me - open or die is a hugely common (and very readable) construct.

        - A rather nasty problem I sometimes pose is to print the answer
to:
                $> perl -e '$x=1; $y=$x+++1; print "x=$x, y=$y\n"'
...
[Correct answer: x=2, y=2]

I'd posit that the correct answer is: "rewrite it."

And adding a space between $x++ and +1 is nowhere near enough.

Even though code like that works, it should never, ever be used.

I'd never base a hiring decision on whether someone has memorized
details of the precedence list at that level.

In fact, other than the huge ones ( 'or' as above, which, IMO,
actually help readability), I'd mainly defer to Oualline's rules
(originally from Practical C Programming):
   1. Multiply and divide before you add and subtract.
   2. Put parenthesis around everything else.

To which, I'd add - if your line of code starts to look too much
like lisp, break it up.

Nifty, tight constructs which rely heavily on precedence rules
are unpleasant to decode (except for fun - the same way perl golf
works), error-prone, and entirely unnecessary.

Of course, I still use certain hugely convenient things like
map and list assignments to hash slices all the time.  I guess
that after using those things for years, I no longer think of
them as nifty and unreadable but rather as fairly standard idioms.
I expect any newbie to be able to look up map and grep and understand
from the docs what they do, but list assignments to hash slices
are not so obvious.

Come to think of it, is there any other language that has such
a thing?

(b) nothing to do with Perl - just assess the person's attitude vs. your
own team's dynamic. To me, this is much more important then the exact
technical skill.

And ability to learn/look stuff up trumps memorizing precedence tables any day...

--d

_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to