From: Joel VanderWerf Date: 2002-09-05T09:38:49+09:00 Subject: Re: Ruby aesthetics Gavin Sinclair wrote: ... > My frame-of-reference for good language design is Ruby. So compared to > Ruby, I would add: > - list comprehensions > - calling procs would look like real functions, not arrays! > e.g. id = proc { |x| x }; id(12) # not id[12] This bothered me a little, OUAT (once upon a time :), but not now. I like being able to use procs and hashes interchangeably. This makes it possible to think of a hash as a function in the sense of a set of ordered pairs: succ_mod_3 = {0=>1, 1=>2, 2=>0} succ_integer = proc {|x| x+1} def cycle(succ_map) x = 0 10.times do print x x = succ_map[x] end end cycle succ_mod_3 # ==> 0120120120 cycle succ_integer # ==> 0123456789 If you want to use procs and methods interchangeably, you have a little more work, but not much--just apply #method.