Method parameters reflection

Discussion in 'Ruby' started by George Moschovitis, Feb 28, 2005.

  1. 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.
     
    George Moschovitis, Feb 28, 2005
    #1
    1. Advertising

  2. George  Moschovitis

    Hal Fulton Guest

    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
     
    Hal Fulton, Feb 28, 2005
    #2
    1. Advertising

  3. >> 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.
     
    George Moschovitis, Feb 28, 2005
    #3
  4. 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.)
     
    Florian Gross, Feb 28, 2005
    #4
  5. In article <>, George
    Moschovitis wrote:
    >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.


    When Ruby gets named parameters, I guess this will be provided. Not quite
    the answer you're looking for ;-)
     
    Tim Sutherland, Mar 6, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. [Gauthier]
    Replies:
    2
    Views:
    14,253
    [Gauthier]
    Dec 3, 2003
  2. jerry051
    Replies:
    2
    Views:
    805
    Oliver Sturm
    Aug 2, 2005
  3. frank
    Replies:
    3
    Views:
    1,494
    Roedy Green
    Aug 20, 2005
  4. Ezra Zygmuntowicz
    Replies:
    2
    Views:
    126
    Ezra Zygmuntowicz
    Jul 10, 2006
  5. Sirisha Pusapati

    Ruby Reflection Method Parameters

    Sirisha Pusapati, Jun 17, 2009, in forum: Ruby
    Replies:
    2
    Views:
    151
    Jörg W Mittag
    Jun 17, 2009
Loading...

Share This Page