Hi,

(11/10/04 4:11), Kurt Stephens wrote:
> Imagine that visit() needs dynamic hooks to visit different types:
> 
> <pre><code class="ruby">
>   def visit(obj, visitor)
>     sel = Symbol.new
>     class Array;   def *sel(visitor); each { | elem | elem.*sel(visitor) }; end; end
>     class Object;  def *sel(visitor); visitor.something(self);              end; end
>     add_visit_methods!(sel)
>     obj.*sel(visitor)
>   end
>   def add_visit_methods!(sel)
>     class Hash;    def *sel(visitor); each { | k, v | v.*sel(visitor);      end; end
>     ...
>   end
> </code></pre>
> 
> The AnonSym send "rcvr.*sel(...)" dispatches, like a normal method send, directly to the appropriate AnonMeth for "*sel".
> visit() can be extended dynamically by adding more AnonMeths bound to "*sel".
> The functional "case ...; when..." version is difficult to extend and maintain and is likely to not perform as well as anon messages.
> This is similar in style to Scheme letrecs, but is object-oriented.

Is this double dispatching system your true goal?  If so, anonymous
symbol doesn't seem the only way nor the best way, for me.

-- 
Nobu Nakada