Hello,

> From: Yukihiro Matsumoto
> Sent: Thursday, June 22, 2000 1:25 PM

>   2) override
> 
>      since Mix-in is an inheritance, usual override rule for method
>      combination is applicable.

I have been surprised with this behavior.  I did not know well
about 'Mix-in'.  In the script below, 'super' in
ConcreteDecorator[AB]#operation works at least as well as I expect.
I realized 'Mix-in is an inheritance'.

// NaHi
P.S.
Thank you for good discussion about Dynamic/Static Typing and DbC.
Those are very stimulative for me.
P.S.2
Sorry for my poor English...


require( '[ruby-talk:03538]' )

module Component
  abstract :operation
end

class ConcreteComponent; implements Component
  def operation()
    p 'ConcreteComponent'
  end
end

module Decorator; implements Component
  attr_accessor :component

  def initialize( component = nil )
    @component = component
  end

  def operation()
    @component.operation()
  end
end

class ConcreteDecoratorA; implements Decorator
  def operation()
    p 'ConcreteDecoratorA:pre'
    super          # !!!!!!!!!!
    p 'ConcreteDecoratorA:post'
  end
end

class ConcreteDecoratorB; implements Decorator
  def operation()
    p 'ConcreteDecoratorB:pre'
    super          # !!!!!!!!!!
    p 'ConcreteDecoratorB:post'
  end
end


if $DEBUG
  # Main component
  c = ConcreteComponent.new()
  # An decoration
  dA = ConcreteDecoratorA.new( c )
  # An decoration
  dB = ConcreteDecoratorB.new( dA )

  aComponent = dB

  # Let's go!
  aComponent.operation()
end