develooper Front page | perl.perl6.language | Postings from February 2005

Re: Valid hash keys?

Thread Previous | Thread Next
Luke Palmer
February 27, 2005 01:17
Re: Valid hash keys?
Message ID:
Autrijus Tang writes:
> Just a quick question: Is Hash keys still Strings, or can they be
> arbitary values? 

They can be declared to be arbitrary:

    my %hash is shape(Any);

> If the latter, can Int 2, Num 2.0 and Str "2" point to different
> values?

That's an interesting question.  Some people would want them to, and
some people would definitely not want them to.  I think the general
consensus is that people would not want them to be different, since in
the rest of perl, 2 and "2" are the same.

The object model that I'm working on actually identifies 2 and "2" as
the same object, indistinguishable in every respect.  But that hasn't
been accepted (or even proposed)... yet.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About