From: Alex Martelli Date: 2001-08-07T18:24:06+09:00 Subject: [ruby-talk:19276] Re: Perl/Python/Ruby common backend (Parrot, can Ruby play too?) "Phil Tomson" wrote in message news:X2Jb7.24637$C7.9671673@e3500-chi1.usenetserver.com... ... > Questions for the Ruby community to ponder: What sorts of features do we > need that might be unique to Ruby? [One that comes to mind: the ability > to extend an existing class.] For the In what sense is this "unique to Ruby"? The following works in Python: class Existing: def one(self): print 'one' anInstance = Existing() def two(self): print 'two' Existing.two = two # and now you can call anInstance.two(), having # extended existing class Existing "after the # fact" -- already-created instances also get # to use the 'extensions' to the class. > most part, I think our needs are very > similar to Python's. It seems to me this similarity fully extends to the issue you've mentioned. I don't know enough Ruby to know if it's quite as dynamic as Python (in Python I can, on the fly, change the class to which a given instance belongs to, add and delete methods from an existing class, add or override a method as defined by a class in a specific instnace only, change a class's bases...) -- any backend able to fully support all of these manipulations should likely provide sufficient functionality for whatever other dynamic aspects (if any) Python itself lacks (I can't think of any, myself, but that may be a failure of imagination:-). I know that Ruby slings around unnamed codeblocks, but I suspect that's just a syntax issue (not affecting the backend) wrt the Python equivalent, which is slinging around _named_ codeblocks (also known as function-objects, method-objects, and other callables). There might be scoping issues, perhaps: in Python, any 'codeblock' [actually always a function, even when unnamed, as in a lambda-form] has its own scope, and can access *but NOT re-bind* variables in enclosing scopes [it can rebind variables in its _global_ scope using the global statement]; if Ruby (like, e.g., scheme) lets a function rebind variables in enclosing blocks (functions), that may be something a back-end needs to provide for, that is extra for Ruby wrt Python. Alex