--------------080906010603050401010206 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Berger, Daniel wrote: > > This doesn't seem to have anything to do with traits: > > http://homepages.ihug.com.au/~naseby/33.html > http://www.iam.unibe.ch/~scg/Archive/Papers/Scha02bTraits.pdf > I like where Ara is going and I like where Naseby went. I think both of these solutions go hand in hand. Included is an example/test usage (yes it runs) of how it appeals to me. Basically they should both be 'traits'. Please see example rb file for more information. Zach --------------080906010603050401010206 Content-Type: text/plain; name raits.rb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename raits.rb" module Trait ## # use append_features so if the user includes Trait it will get everything # from with AccessorTrait and MethodTrait also. see def self.append_features( aModule ) constants.each { |c| aModule.instance_eval( "include #{c}" ) } end module AccessorTraits # include Ara's code here def trait( arg ) puts "#{self} has trait #{arg}" end end module MethodTraits # include here the functionality from # http://homepages.ihug.com.au/~naseby/33.html def require_method( arg ) puts "#{self} has required method #{arg}" end end end ## Example Usage class A # includes Trait, so it gets all of Traits functionality include Trait end A.new.trait( :a ) A.new.require_method( :reqA ) puts class B # includes AccessorTraits, only gets AccessorTraits functionality include Trait::AccessorTraits end begin B.new.trait( :b ) B.new.require_method( :reqB ) rescue ex puts ex end puts class C # includes MethodTraits, only gets MethodTraits functionality include Trait::MethodTraits end begin C.new.trait( :b ) rescue ex puts ex C.new.require_method( :reqC ) end puts --------------080906010603050401010206--