Front page | perl.perl5.porters |
Postings from September 2002
Re: Collections
Thread Previous
From:
Michael G Schwern
Date:
September 29, 2002 00:03
Subject:
Re: Collections
Message ID:
20020929070320.GF3858@ool-18b93024.dyn.optonline.net
On Sun, Sep 29, 2002 at 06:44:28AM +0200, Christian Jaeger wrote:
> Maybe the coolest thing would be when perl hashes would just accept
> refs as keys without stringification, i.e. keys %hash would then
> return refs in such cases. Maybe it would be possible to tie a hash
> and implement it through XS to get that thing?
What you want to do really should be possible. Perl doesn't DWIM because of
what is basically an exposed performance hack.
Unlike nearly everything else in Perl, hash keys are stored as simple C
strings. This was probably done to save a bit of speed/memory. Nearly
everything else is internally stored as an SV (scalar value). The fact that
hash keys are raw strings causes a small bucket of problems internally and
externally.
Might it be time to do away with this and finally elevate hash keys to full
SVs?
--
Michael G. Schwern <schwern@pobox.com> http://www.pobox.com/~schwern/
Perl Quality Assurance <perl-qa@perl.org> Kwalitee Is Job One
If the women don't find you handsome, they should at least find you handy.
-- Red Green
Thread Previous