From: gabriele renzi Date: 2004-01-13T17:26:37+09:00 Subject: Re: faster integer arithmetics & arbitrary precision floating number il 12 Jan 2004 19:21:31 -0800, GGarramuno@aol.com (GGarramuno) ha scritto:: > >> >> still, you can't reopen base classes in python, IIRC.. > >No, you can't, but you can now inherit from them and create your own >subclass and any function that uses the base class (say ints) can take >your new class type, too. a great enhancement yes :) Still, I was just saying that you may bve sure that int.__add__ will be the same, and thuis can do some little optimization, that can't be done in ruby. >To be honest, I see this as a better approach. You get the speed >benefit and safety, too. I have to admit I partiall agree. OTOH I believe that consistency is something important, I would bother matz if Fixnums were not going to be editable :) >I am still not 100% convinced that Ruby's feature of reopening base >classes is truly a benefit. I see it as a long string of rope for >hanging yourself in the long run, perhaps. I had a long discussion about this with a pythoneer time ago :) I believe that this won't ever cause you problems (other languages allows you to do this, and I don't get the difference of being able to modify str.__add__ against being able to modify re.compile() ). He, was quite frightened of this, and suggested something like a "switch" to block this behaviour. But don't forget that you'll get a warning if you're going to redefine an existing method (and to get an exception, for some level of $SAFE) >I mean, for my own personal code, I see the ability to extend base >classes as a great benefit. I know in a year or so I would easily >have a String, Fixnum, etc. classes with tons of new things in them. >But so would most ruby users, I assume. I fret at the prospect of one >day trying to integrate two libraries or two pieces of code that have >an extended base class with similar named functions that do completely >different things. little stuff added, base classe4s are quite complete. this project collects a lot of different classical 'base class add-on' http://extensions.rubyforge.org/rdoc/index.html Not having them in a stdlib doesn't mean we can't chose to avoid code duplication ;) >But then again, I am quite new to Ruby. I am sure this issue might >have already arised, and there may be a workaround for it? >Can extensions to base classes be kept within a specific namespace >only? namespace should bepresent in rite, IIRC, dunno how to do it now..