From: "Berger, Daniel" Date: 2005-03-23T00:06:37+09:00 Subject: Re: unifying hash and proc syntax > -----Original Message----- > From: Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU] > Sent: Monday, March 21, 2005 10:02 PM > To: ruby-talk ML > Subject: unifying hash and proc syntax > > > Hey, crazy idea. Why not use the same syntax for hashes and > arrays? If Ruby had a "List" superclass from which Array and Hash descended, instead of the Enumerable mixin strategy, this would have been easier I think. Presumably (and I'm totally guessing here) a list would have been anything between square brackets: [1,2,3,4].kind_of?(List) # true [1,2,3,4].kind_of?(Array) # true [1,2,3,4].kind_of?(Hash) # false [1 => 2, 3 => 4].kind_of?(List) # true [1 => 2, 3 => 4].kind_of?(Hash) # true [1 => 2, 3 => 4].kind_of?(Array) # false (I believe someone else proposed this syntax earlier.) This is more along the path that Perl took, where hashes and arrays are both lists. Then the {} would then be free, FREE, to be used for whatever nefarious purposes we could devise. Not being a language designer, I have no idea if this is better or worse, if the List superclass is really necessary (i.e. could we still use a mixin strategy?), or if it would even be possible to implement in Ruby 2.0. Who knows? Maybe I'll learn to design a language someday and give this a shot to see how it pans out. :) Regards, Dan