Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: strings in boolean context Message-ID: <7606@jpl-devvax.JPL.NASA.GOV> Date: 29 Mar 90 23:08:31 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 27 In article schwartz@psuvax1.cs.psu.edu (Scott Schwartz) writes: : Is it really a good idea to allow strings automagically be coerced to : integers in boolean context? I think changing that behavior is nicer : than some of the fixed to Felix's program that have floated by. Would : that break any old code? First of all, no coercion happens in a boolean context. If it has a valid string value, it's false if it's specifically "0" or "". Otherwise, if it has a numeric value, it's false if it equals 0.0. Otherwise, it's undefined and therefore false. Suppose we change "0" to be true. What do you do if it's both a number and a string? The fact is, when you say literal 0, it is store both ways (currently, anyway). I can't really make people keep track of what's been evaluated in which context. It's bad enough to describe magical increment in those terms. I think you really want to say ne '' when you mean that, like Tom says. It's just as fast as the numeric comparison, anyway. : By the way, in the newly distributed lib/syslog.pl there is a hardcoded : reference to /usr/local/lib/perl/syslog.h. Shouldn't Configure fix : that up? Not directly. But it should just do 'syslog.h', and rely on @INC (which is, in fact, set up by Configure). Larry