From: Benedikt Huber Date: 2005-01-18T04:06:08+09:00 Subject: Re: Fwd: [suby-ruby] Your all time desired fundemental Ruby mod On Sun, 16 Jan 2005 09:23:56 +0900, trans. (T. Onoma) wrote: > Let say you're Matz, but without any of the pressures of keeping up with a > previous version of Ruby. What one thing above all others would you like to > see differ about Ruby? > > T. 1) First of all, a faster VM, including opcode (YARV ?) 2) A "strict mode" for instance variables (like perlish my @var or attr_reader style declaration) - typos are quite subtle if they raise no Exception immidiatly 3) Support for role-based programming. ad 3) Solving the last ruby quiz, I used the following workaround for a simple role change (only 1 role). Are there more sophisticated solutions/frameworks available ? #!/usr/bin/ruby class Role def initialize(object) @__o__= object end def method_missing(symbol,*args) @__o__.send(symbol,*args) end def __role__=(object) @__o__ = object end undef_method :class,:display,:dup,:initialize_copy,:inspect,:instance_eval undef_method :instance_of?,:instance_variable_get,:instance_variable_set undef_method :instance_variables,:is_a?,:kind_of?,:method,:methods undef_method :private_methods,:protected_methods,:public_methods undef_method :remove_instance_variable,:respond_to?,:send undef_method :singleton_method_added,:singleton_method_removed undef_method :singleton_method_undefined,:singleton_methods undef_method :to_a,:to_s,:type end # Testing class Leaf attr_accessor :animal end class Node attr_accessor :c1,:c2 end a = Role.new(Leaf.new) puts a.inspect puts a.class b = Role.new(Leaf.new) a.__role__=Node.new a.c1=b puts a.inspect puts a.class