On Mon, 2005-03-07 at 11:22, Palit, Nilanjan wrote:
> -----Original Message-----
> > From: Greg London [mailto:[EMAIL PROTECTED] 
> > Sent: Monday, March 07, 2005 11:17 AM
> > 
> > As for the triple-plus operator   ;)
> > I'd think perl would take x, do a "++" on it,
> > get 2, and then do the "+1" on it to get three.
> > But oh well. just won't use that in my code.
> 
> No. In Perl (or C), "$x++" => use & then increment, whereas "++$x" =>
> increment & then use. Thus the expression will use the existing value of
> x (1) to compute the value of y & then increment x itself.

Correct. If you wanted obscure, you probably wanted:

        $y=$x+++-+1

Which is arguably not a useful feature, but still quite legal. Deparse
is enlightening here, as you will notice that the last "+" is not
represented (it's considered part of the number, and lost after
tokenization), where the - is an actual operator ("unary:-").

This is why you can't reverse it:

        $y=$x+++ +-1

yields a very different deparse (you can't string all four "+" without
whitespace because it will be read as "($x++)++", which is invalid.

None of this addresses the value of obscurity in an interview (I think
it has its place, but needs to be moderated).


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

Reply via email to