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

Re: k, v

Thread Previous | Thread Next
Uri Guttman
September 24, 2005 07:37
Re: k, v
Message ID:
>>>>> "J" == Juerd  <> writes:

  J> Hashes are full of convenience, and Huffman would be proud:
  J>     %hash.keys      %hash>>.key
  J>     %hash.values    %hash>>.value
  J>     %hash.kv        zip(%hash.keys, %hash.values)

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

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

huffman has its limits too. in general having single letter names for
anything is a poor idea. it makes it hard to search for, you limit it to
only one thing that can use that letter, it isn't always easy to
remember what a given letter is, etc. keys and values are short enough
and read much better. kv works because keyvalues is clunky and too
long. i wouldn't have minded .pairs or .each instead of kv. but alias
methods are easy to add. 


Uri Guttman  ------  --------
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------

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