Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!newstop!texsun!letni!mic!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: More ** weirdness Message-ID: <109199@convex.convex.com> Date: 24 Nov 90 02:38:04 GMT References: <109161@convex.convex.com> <9077@cognos.UUCP> Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 37 In article <9077@cognos.UUCP> alanm@cognos.UUCP (Alan Myrvold) writes: > (quoting a posting of mine) >well for me (on a Sun), it is exactly opposite (as I would expect). You're right -- I got the signs switched. Sorry. What I wanted to know was why the Sun version seemed to be able to take the log of a negative number, and moreover do the right thing. I always expected perl to be checking first to make sure it never called the log of a negative number, and remembering to restore the sign on odd integral exponents. >What surprises me is the need for parentheses when using '**' with 'print'. >On both PL 36 and 41, That's because it looked like a function to perl. The list operators (like print, unlink, sort, chown, ...) are peculiar creatures at best. They normally gobble up all their operands, as in func x, b, c, d; but if they see a paren as the first token, they consider it the start of the argument list. Because they're lowest in precedence (kind of), func x op y; # like func(x op y); func(x) op y; # like func(x) op y; func (x) op y; # like func(x) op y; It's that last case that bites you. It may make some sense if you let func==rand, but when func==print and op==+ or the like, it's a surprise that print -2 + 2; print (-2) + 2; should do such different things. It's also when what you thought was a list separating comma becomes a scalar arithmetic comma and throws always returns the value of its RHS operand. So beware that print i+2,3,4,5; # like print(i+2,3,4,5); and print (i+2),3,4,5; # like print(i+2),3,4,5; are different. --tom