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

Re: The Sort Problem: a definitive ruling

Thread Previous | Thread Next
From:
Luke Palmer
Date:
February 20, 2004 14:07
Subject:
Re: The Sort Problem: a definitive ruling
Message ID:
20040220214931.GA6458@babylonia.flatirons.org
Smylers writes:
> Joe Gottman writes:
> 
> >       sort {$_.key} (1=> 'a', 10 => 'b', 2 =>'c');
> > 
> > There is nothing in the signature of the key-extractor to suggest that
> > all the keys are numbers, but as it turns out they all are.
> 
> Are they?  I'd been presuming that pair keys would always be strings (as
> for hashes in Perl 5), and that the C<< => >> operator would
> automatically quote a preceding word, stringifying it (as in Perl 5).
> So the keys above are strings, albeit ones composed only of digits.
> 
> Of course that doesn't actually help with your question, since there are
> other data structures of which the same could be asked.

I think you're forgetting what language you're talking about.  Those are
numbers.  After this statement:

    $x = '345';

C<$x> is a number.  I should hope it would be treated as one during
multimethod dispatch.

However, I'm not saying this with authority.  I'm just extrapolating.
If it's not correct, I'd appreciate that someone who knows correct me.

Luke

Thread Previous | Thread Next


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