I have come up with the following syntax extension:

(define-syntax define/on-delegate
  (syntax-rules ()
    ((_ delegate-object (method-name ...))
     (define/public (method-name ...)
       (send delegate-object method-name ...)) )))

It's working flawlessly in it's current only use:

A card game supports different rule sets / variants implemented
as different metaobjects. The rule implementation interface of the
coordinator / controller metaobject delegates the corresponding
part of it's interface to the current rule object.

    (define/on-delegate current-rules
      (can-place-on-flower-bed? flower flower-bed))

    (define/on-delegate current-rules
      (can-place-on-foundation? flower foundation))

    (define/on-delegate current-rules
      (can-place-on-bucket? flower bucket))

Right now this works great for me and I want to present this to you.
As a pure syntax transformation it saves some typing and enhances
readiblity. But I'm not sure about the name or other existing solutions?

Does define/on-delegate as name make sense in the Racket world? As far
as I know C#'s concept of delegate is like a "(define a b)" in Scheme.

Are there other approaches to capture, abstract and simplify the delegation
scheme in object oriented programming?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to