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

k, v

Thread Next
September 24, 2005 06:11
k, v
Message ID:
Hashes are full of convenience, and Huffman would be proud:

    %hash.keys      %hash>>.key
    %hash.values    %hash>>.value
    %hash.kv        zip(%hash.keys, %hash.values)

One thing occurred to me: if hashes are worth all this, then why not
abbreviate "keys" further to "k" (as in "kv"), and "values" to "v" (as
in "kv"). This would allow us to rename "key" to "k" and "value" to "v"
too, resulting in:

    %hash.k         %hash>>.k
    %hash.v         %hash>>.v
    %hash.kv        zip(%hash.k, %hash.v)

With hashes and pairs, I don't think there could be any confusion over
the meaning of "k" and "v", just like "kv" works without explanation. 

(Not having to type "alue" also makes it easier for a pair to NOT
evaluate to its value, but that's another thread.)


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