develooper Front page | perl.perl6.language.data | Postings from September 2000

Re: RFC 196 (v1) More direct syntax for hashes

Thread Previous | Thread Next
From:
Nathan Torkington
Date:
September 7, 2000 21:23
Subject:
Re: RFC 196 (v1) More direct syntax for hashes
Message ID:
14776.27001.235653.633126@prometheus.frii.com
Michael G Schwern writes:
> > C<reset %hash> should reset the hash iterator, instead of calling
> > C<keys> or C<values> as is currently the case.
> 
> Sounds good, except the name.  reset() already does something.
> Currently, reset() is for clearing large swaths of global variables (a
> dubious feature) and for reseting ?pattern? searches.  Two weird
> features crammed into one keyword.  Shoving a third in doesn't seem
> pleasent.
> 
> Either think up a better keyword, or remove those two crufty features.

I was expecting those two crufty features to be removed.  If they
aren't, a third won't hurt.

> > This would be equivalent to:
> > 
> >   foreach ($k,$v) (map { $_ => $hash{$_}
> > 		   sort
> > 		   keys %hash)
> >   { ... }
> 
> What you proposed and what you put in your example doesn't quite play
> out.  C<sort keys %hash> returns just the sorted keys of %hash, but
> your foreach example implies that both keys and values would be
> returned, sorted by key.  Both would be useful.  

That's what the map is for.  (modulo syntax error in the map :-)

Nat

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