2009/10/15 Nicholas Clark <nick@ccl4.org>: > On Thu, Oct 15, 2009 at 09:40:44AM +0100, Nicholas Clark wrote: > >> Why *not* deprecate defined(%hash)? >> It does nothing that scalar %hash doesn't do. >> >> Historically it was used because of a quirk of the implementation - it would >> report on whether space had ever been allocated for the hash. So it would >> become true when the first key was created (or space for it reserved), and >> would remain true if all the keys were deleted. It would only become false >> if undef %hash was used to free up the space. >> >> Right now there's a hack in toke.c to help support defined %hash, for the >> specific intended use of defined %some::stash:: >> >> The intent is "was this package loaded?". I can't see any use case where >> "did this package define any symbols?" differs. >> >> I'd like to get rid of hacks. > > Actually, I suspect that it was also an anti-pattern, because in scalar > context it used to be that C<defined %hash> was faster than C<%hash> > > Yves fixed that some years ago. I did? I thought i posted a patch that made if (scalar %hash) as fast as if (%hash) (or the other way around, whatever). But that it was rejected at the time, possibly because it was too close to release. I dont recall if it got re-added afterwards. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next