> From: Stephen White [mailto:spwhite / chariot.net.au] [...] > > class Fred < String > > def exec; self << self end > > end > > I don't understand how that causes a problem? > > I'm an OOP newbie. Please be gentle. :) and I am OOP wanebe ... > If I understand this part of your proposal correctly (note I like your comments about do ... end versus {..} but don't know if this would really re-solve all problems) behavior of your proposed syntax change by simply replacing also objects ``x'' with ``x.exec'' unless x is on the left hand side of an assignment for example x = x + a is replaced by x = x.exec + a.exec In my example this would translated into ``def exec ; self << self.exec end'' (To be true to your proposal one might even say that the return of any #exec call should be translated into def exec; do calculation; res.exec end) The mere existence of such a stupid Object would cause the interpreter to crash because as soon as the interpreter scans such an object the cataclysmic call to #exec would be initiated - right now such an object is harmless - unless you directly or indirectly call #exec - for example in a simple assignment ``a = x'' this would never happen. This obviously very silly example is indicative that your proposal has simply too many side effects especially when combined with self altering methods like #push, #reverse!, etc.. The beauty of something like #coerce is that it only springs into acting for some methods and that you can integrate your own classes into ruby's build-in class system. In your example it's as easy as ------------- $ ruby coerce.rb Complex(-17.0, 2) Complex(27, -2) Complex(-2, 2.0) 10.0+0i "12345hello" 12345hello ------------- require 'Complex' class Fred def initialize(var);@r = var end def coerce(l); return @r.coerce(l) end def inspect; @r end def +(l); @r + l end def -(l); @r - l end end a = Fred.new Complex.new (3,2) p b = a - 20.0 p c = 30 - a p d = Complex.new(1,4.0) - a puts b + c a = Fred.new "12345" p b = a + "hello" puts b # and c = "world" + a would fail # since String does not sport a #coerce [...] Christoph