From: Robert Dober Date: 2006-09-16T00:22:59+09:00 Subject: Re: arbitrary indexes ------=_Part_91717_1075556.1158333728386 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/15/06, Jason Nordwick wrote: > > In my original message, I asked for people not to answer "change the > behavior of [] yourself" beause changing the base semantics of indexing i= s > likely to play havoc with the other developers (we have about 5 writing w= ith > the same code) or possibly another package we import (this type of collis= ion > has already happened once to us on a relatively small project, and we had= to > turn off an couple inlined C method because of it). > > "Change the base behavior of this builtin" and "write it in C" have becom= e > the chief dodges of the Ruby community to any substantive criticism. I no= w > have a file I load that includes base extensions to the language that sho= uld > probably be supplied by the system, and that files seems to just keep > growing. Ruby is become less productive of a langauge because of it becau= se > I spend more time either searching for these functions like "values_at", > writing extentions to [] or such, and then debugging them when the > interactions with other parts of the system fail. I take all criticism for not supporting criticism on ruby. Well I just think your attidue is not very useful, have you already made some suggestions to ISO for adding features to C? Or to ANSI for some additional features for Ada? Ruby gives you enourmous power to extend base classes and much more, I fail to see how this is a problem, a good toolbox, teaching people to use conventions, documenting your toolbox, project management etc. etc. is beyond the responsability of Ruby. That all said, who knows if Matz likes your ideas... Cheers Robert -j > > > MonkeeSage wrote: > > Jason Nordwick wrote: > >> Of course I don't believe that going from value_at to [] would make > >> my code faster, just that it would make it more compact. We started > >> using Ruby for some moderately heavy numerics, and I haven't been > >> able to be as concise (or productive) as I wish (or thought from what > >> others told me). > > > > So define your own implementation! That's one of the things that makes > > working in ruby so productive. > > > > class Array > > def [](*args) > > if args.size =3D=3D 1 > > at(*args) > > else > > values_at(*args) > > end > > end > > end > > > > a =3D [1,2,3,4,5,6,7,8,9] > > p a[2] # =3D> 3 > > p a[2,4,6] #=3D> [3, 5, 7] > > > > Regards, > > Jordan > > > > > > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_91717_1075556.1158333728386--