[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Method Dispatching

T. Onoma

1/13/2005 10:12:00 PM

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.


2 Answers

Yukihiro Matsumoto

1/13/2005 11:54:00 PM

0

Hi,

In message "Re: Method Dispatching"
on Fri, 14 Jan 2005 07:12:04 +0900, "trans. (T. Onoma)" <transami@runbox.com> writes:

|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. Onoma

1/14/2005 12:38:00 AM

0

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)"
<transami@runbox.com> writes:
| |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.