Path: utzoo!attcan!uunet!wuarchive!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: Yet another BUG in sort and package in PL#37 Message-ID: <10139@jpl-devvax.JPL.NASA.GOV> Date: 28 Oct 90 10:20:18 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 24 In article ishii@hexard.co.jp (Koji Ishii) writes: : : Larry said $a and $b in sort function is bound to current package : at PL#36. But it seems to have a bug, please look at package yy in : following sample. Here, $a and $b are not bound to package yy but : package xx. Yep, it's a bug. It's binding to the $a and $b of the first package in which a sort is called. The result of a bit of leftover code that assumed that packages were purely lexical. Well, hey, this is why it isn't version 4.0 yet... : I wonder why they are bound to such names as $a and $b, not to : $_[0] and $_[1]. This is the only case where perl requires special : names to programmers. Could you explain if I'm missing something? It's only for efficiency. It's more overhead to set up an array than a couple of scalar variables and more overhead to dereference the array elements once they're in the array, and since the sort routine gets called very heavily, we compromise a little. Besides, it makes the sort routines look almost algebraic. :-) Larry