On 11/18/2003 12:02 PM, Yukihiro Matsumoto wrote:

>Hi,
>
>I'd recommend you to check CLOS.
>  
>

I don't know if this will help or hinder someone's understanding, but 
here is some CLOS that mimics the Ruby2 actions (or is that the other 
way around? :-) )

; define a pretty useless class
(defclass foo () ())

; define a method called 'bar' that  just prints 'inside-bar'
(defmethod bar ((x foo))
  (print 'inside-bar))

; define a method that will get executed before 'bar
(defmethod bar :before ((x foo))
  (print 'before-bar))

; define a method that will get executed after 'bar
(defmethod bar :after ((x foo))
  (print 'after-bar))

; define a method that will wrap any call to 'bar
(defmethod bar :around ((x foo))
  (print 'around-bar-before)
  (call-next-method)
  (print 'around-bar-after))

; create an instance of class 'foo' and assign it to slot 'x'
(setq x (make-instance 'foo))

; call the bar method on our instance 'x'
(bar x)

Yielding the following:

AROUND-BAR-BEFORE
  BEFORE-BAR
    INSIDE-BAR
  AFTER-BAR
AROUND-BAR-AFTER

Note that in bar :around, the (call-next-method) is doing what Ruby2's 
proposed call to 'super' will do.

Does that help?
Joey

-- 
Never trust a girl with your mother's cow,
never let your trousers go falling down in the green grass...

http://www.joeygibson.com
http://www.joeygibson.com/blog/life/Wisdom.html