Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Method parameters reflection

11 views
Skip to first unread message

George Moschovitis

unread,
Feb 28, 2005, 3:43:17 AM2/28/05
to
Hello everyone,

I would like to use some kind of reflection to get the parameters of a
method.
For example:

class MyClass
def simple_method(last_name, name)
end
end

method_params(MyClass, :simple_method)
=> [:last_name, :name]

I have implement this using ParseTree, but since ParseTree uses
RubyInline which requires a C compiler, and AFAIK is not portable, I
would like a better solution.

Anyone has an idea?

George.

Hal Fulton

unread,
Feb 28, 2005, 8:46:17 AM2/28/05
to
George Moschovitis wrote:
> Hello everyone,
>
> I would like to use some kind of reflection to get the parameters of a
> method.

[snip]

I have wanted this, too, but AFAIK there is no
good solution at present.


Hal

George Moschovitis

unread,
Feb 28, 2005, 9:05:45 AM2/28/05
to
>> I would like to use some kind of reflection to get the parameters of a
>> method.
>
>
> [snip]
>
> I have wanted this, too, but AFAIK there is no
> good solution at present.

ParseTree is a great solution, but it uses RubyInline which
requires a C compiler (typically gcc). No luck with Windows.

I _think_ ParseTree could use RubyDL like EvilRuby. This would be
something nice to have in Ruby 1.9. In the meantime I will try to play a
bit with EvilRuby, or perhaps Florian Gross could help here :) :)

regards,
George.

Florian Gross

unread,
Feb 28, 2005, 9:40:45 AM2/28/05
to
George Moschovitis wrote:

> ParseTree is a great solution, but it uses RubyInline which
> requires a C compiler (typically gcc). No luck with Windows.
>
> I _think_ ParseTree could use RubyDL like EvilRuby. This would be
> something nice to have in Ruby 1.9. In the meantime I will try to play a
> bit with EvilRuby, or perhaps Florian Gross could help here :) :)

Well, EvilRuby does not do this either as it's quite some work to dig
through all the pointers in that structures.

And porting ParseTree over to Ruby/DL could be problematic as well...
(It does a lot of its logic in C and Ruby/DL does AFAIK not yet work
correctly on 64 bit machines.)

Tim Sutherland

unread,
Mar 6, 2005, 2:27:54 AM3/6/05
to
In article <1109580197....@o13g2000cwo.googlegroups.com>, George

When Ruby gets named parameters, I guess this will be provided. Not quite
the answer you're looking for ;-)

0 new messages