Method Dispatching

T

trans. (T. Onoma)

I've touched on this before with the idea of a "pre" method missing, but it
has come up again for me (AOP) and I really would like to get some general
input on the subject.

The idea is essentially that if a #method_dispatch callback method were
defined, then calls would be routed through it. For example:

class C
def method_dispatch(method, *args)
case method
when 'hi', 'hey'
hello(*args)
else
send(method, *args)
end
end
def hello(name)
puts "Hello, #{name}."
end
end

C.new.hi("Bob") #=> Hello, Bob.

#send of course must bypass #method_dispatch, or perhaps there would be a
variant method for this.

The questions I have about this:

1. Might this be a generally useful/powerful mechanism?
2. What kind of problems might this create?

Something like this certainly is useful for AOP, though I don't think the lack
of it is necessarily a show stopper. But that's why I'm wondering about its
more general implications.

Thanks,
trans.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Method Dispatching"

|The questions I have about this:
|
| 1. Might this be a generally useful/powerful mechanism?

It is too low level for AOP. It is difficult to manage multiple
method wrappers or per method modifiers.

| 2. What kind of problems might this create?

Performance comes to my mind first. Probably avoiding infinite
loop (thus invocation of method_dispatch should be treated
specially) comes next.

|Something like this certainly is useful for AOP, though I don't think the lack
|of it is necessarily a show stopper. But that's why I'm wondering about its
|more general implications.

I think AOP should be built in to the language in more higher level.

matz.
 
T

trans. (T. Onoma)

On Thursday 13 January 2005 06:54 pm, Yukihiro Matsumoto wrote:
| Hi,
|
| In message "Re: Method Dispatching"
|
| on Fri, 14 Jan 2005 07:12:04 +0900, "trans. (T. Onoma)"
| |The questions I have about this:
| |
| | 1. Might this be a generally useful/powerful mechanism?
|
| It is too low level for AOP. It is difficult to manage multiple
| method wrappers or per method modifiers.
|
| | 2. What kind of problems might this create?
|
| Performance comes to my mind first. Probably avoiding infinite
| loop (thus invocation of method_dispatch should be treated
| specially) comes next.
|
| |Something like this certainly is useful for AOP, though I don't think the
| | lack of it is necessarily a show stopper. But that's why I'm wondering
| | about its more general implications.
|
| I think AOP should be built in to the language in more higher level.

Good points. Although I point out that what I'm working on is the low-level
underpinnings of AOP. Nonetheless I think your "manage" point is enough to
push me away from this particular ally. And it saves me some work too! ;)

Thanks,
trans.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top