develooper Front page | perl.perl5.porters | Postings from August 2001

Re: two-way hashes

From:
Brent Dax
Date:
August 2, 2001 19:24
Subject:
Re: two-way hashes
Message ID:
FJELLKOPEAGHOOODKEDPOEJHCDAA.brentdax1@earthlink.net
# >>>>> "Brent" == Brent Dax <brentdax1@earthlink.net> writes:
# 
# Brent> I think a much better way to support something like this would
# Brent> be something like C<%hash.invert{value}> (where invert returns
# Brent> a magic hashref with the desired functionality).  This avoids
# Brent> the problems of a new, funky syntax but still provides the
# Brent> requested feature.  (Implementation is a whole 'nother can of
# Brent> worms, however...)
# 
# Implementation is trivial:
# 
#   {+reverse %hash}
# 
# :-)

Except you lose the lvaluability he mentioned.  *That's* why you'd need the magic.

--Brent Dax
brentdax1@earthlink.net



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About