Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Does it have to be like this? Keywords: octal Message-ID: <9951@jpl-devvax.JPL.NASA.GOV> Date: 12 Oct 90 20:46:20 GMT References: <1990Oct12.060936.7501@athena.mit.edu> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 47 In article <1990Oct12.060936.7501@athena.mit.edu> ccount@athena.mit.edu (Craig A Counterman) writes: : 010 < 10. I can deal. : 010.0 > 10. This bugs me. : : (Patchlevel 28) : : I know what's happening, I hope it can be changed. It's just too obscure. : : The annoying thing is that I discovered this when discussing a C : compiler's annoying failure to deal with '-08.123'. I wanted to show : him how a _good_ language would handle it. Oh boy. You want a "good" language, don't look here. Perl is pathologically eclectic, and like Unix itself, generally gives you enough rope to hang yourself. Other than the fact that it almost always does what you want, it's a lousy language. I'm not a language designer. I'm just a squeaky-wheel greaser. : Oh, and: : : $x = 010.; : : is a syntax error. : : just so you know, : Craig : : PS: To explain for the the confused: a leading 0 on an integer : indicates that the number is in octal, e.g. '077'. When perl 3.0/28 : sees '010', it's taken to be 8 so (010 < 10). Ok, so far so bad. But : (correct me if I'm wrong, Larry) 010.0 is parsed as the numbers 8 and : 0, with the '.' indicating a string concatenation, so 010.0 is 80 and : (010.0 > 10). That's correct. : Now, as an exercise, explain why 010.0 - 010.0000 == 720 Hint: "." and "-" are both left associative and have the same precedence. : Oh boy. Right. I suppose I should point out that you're the first person to point this out. Obviously not a major malfunction... It might be worth a warning with -w though. Larry