Class of the calling Object, is there someway to fetch it (from thecalled method)?

Discussion in 'Ruby' started by thunk, Mar 27, 2010.

  1. thunk

    thunk Guest

    Hi again,

    SPECIFIC QUESTION:
    How can I fetch the Class name of the calling Object?
    (The module that contains the class of the calling Object might be
    useful/necessary in the future.)

    NOTES:
    I checked the 'caller' stack and it doesn't show up there. Searched
    this forum, googled, and it is was not found.

    The calling Method was found right off.



    A SNIPPIT FROM MY TEST CODE:
    (this might provide some clue to the general utility?)

    class TestingClass

    def initialize
    @wB = WhiteBoard.new
    @satz1 =
    end

    def calling_method1
    age = @wB.get_note:)AGE, 19)
    puts "defaulted age = " + age.to_s
    @wB.put_note:)test, 12)
    @wB.put_note:)test, 16) #just overwrites, handy?!
    age = @wB.get_note:)test)
    puts "age = " + age.to_s # => 16
    end

    def calling_method2
    @wB.set_id( :ALF )
    @wB.put_satz:)TestingClass, :calling_method2, @satz1)
    #put_satzAr(.... pushes the satz struct onto a automatic
    stack

    #would become just
    #@wB.put_satz(@satz1)
    #....if I could fetch the Class
    end

    def calling_method3
    @wB.set_id( :ALF )
    satz = @wB.get_satz:)TestingClass, :calling_method2)
    puts "satz in calling_method3 = " + satz.inspect #(this
    works)
    end

    end
     
    thunk, Mar 27, 2010
    #1
    1. Advertising

  2. thunk

    Ryan Davis Guest

    Re: Class of the calling Object, is there someway to fetch it (from the called method)?

    On Mar 26, 2010, at 18:15 , thunk wrote:

    > def calling_method1
    > age =3D @wB.get_note:)AGE, 19)
    > puts "defaulted age =3D " + age.to_s
    > @wB.put_note:)test, 12)
    > @wB.put_note:)test, 16) #just overwrites, handy?!
    > age =3D @wB.get_note:)test)
    > puts "age =3D " + age.to_s # =3D> 16
    > end


    This is not a test (nor is any of the rest of your file).

    Also, it hints very much that you're reimplementing rinda, as I've =
    suspected for a while. Google for Linda TupleSpace for more info.
     
    Ryan Davis, Mar 27, 2010
    #2
    1. Advertising

  3. thunk

    thunk Guest

    Re: Class of the calling Object, is there someway to fetch it (fromthe called method)?

    On Mar 26, 9:45 pm, Ryan Davis <> wrote:
    > On Mar 26, 2010, at 18:15 , thunk wrote:
    >
    > >    def calling_method1
    > >        age = @wB.get_note:)AGE, 19)
    > >        puts "defaulted age = " + age.to_s
    > >        @wB.put_note:)test, 12)
    > >        @wB.put_note:)test, 16)   #just overwrites, handy?!
    > >        age = @wB.get_note:)test)
    > >        puts "age = " + age.to_s   # => 16
    > >    end

    >
    > This is not a test (nor is any of the rest of your file).
    >
    > Also, it hints very much that you're reimplementing rinda, as I've suspected for a while. Google for Linda TupleSpace for more info.



    1. I don't know from "tuples" - all I "need" are hashes. Somebody
    also mentioned Graphs. I'm happy with my set of conventions and these
    hashes for my purposes.

    2. I looked at Rinda and didn't understand it.

    3. Anything that works for me in 60 lines and I have complete control
    over is not something I am personally interested in replacing with
    something I don't understand or see a need to.

    4. Any thing I write that "tests" is a "test" to my simple logic. I'm
    spending a great deal of time implementing self-tests and all such and
    have written and supervised some pretty big projects in other
    languages. I'm in awe of what Ruby can do but I don't really think
    you guys, as awesome as you all are, have any place telling that I'm
    not testing. Save that for the rookies. Or maybe you have redefined
    what "testing" means. As an old QC guy, i'd have to wonder if you can
    do that.
     
    thunk, Mar 27, 2010
    #3
  4. thunk

    thunk Guest

    Re: Class of the calling Object, is there someway to fetch it (fromthe called method)?

    On Mar 26, 10:07 pm, thunk <> wrote:
    > On Mar 26, 9:45 pm, Ryan Davis <> wrote:
    >
    > > On Mar 26, 2010, at 18:15 , thunk wrote:

    >
    > > >    def calling_method1
    > > >        age = @wB.get_note:)AGE, 19)
    > > >        puts "defaulted age = " + age.to_s
    > > >        @wB.put_note:)test, 12)
    > > >        @wB.put_note:)test, 16)   #just overwrites, handy?!
    > > >        age = @wB.get_note:)test)
    > > >        puts "age = " + age.to_s   # => 16
    > > >    end

    >
    > > This is not a test (nor is any of the rest of your file).

    >
    > > Also, it hints very much that you're reimplementing rinda, as I've suspected for a while. Google for Linda TupleSpace for more info.

    >
    > 1.  I don't know from "tuples" - all I "need" are hashes.   Somebody
    > also mentioned Graphs.  I'm happy with my set of conventions and these
    > hashes for my purposes.
    >
    > 2. I looked at Rinda and didn't understand it.
    >
    > 3. Anything that works for me in 60 lines and I have complete control
    > over is not something I am personally interested in replacing with
    > something I don't understand or see a need to.
    >
    > 4. Any thing I write that "tests" is a "test" to my simple logic.  I'm
    > spending a great deal of time implementing self-tests and all such and
    > have written and supervised some pretty big projects in other
    > languages.  I'm in awe of what Ruby can do but I don't really think
    > you guys, as awesome as you all are, have any place telling that I'm
    > not testing.  Save that for the rookies.  Or maybe you have redefined
    > what "testing" means.  As an old QC guy, i'd have to wonder if you can
    > do that.


    Project perspective wise this "WhiteBoard" thing is a very small part
    of a much larger project. It looks like it can have a role in storing
    and retrieving "communications" between DSLs that are handling the
    "Boids" and between HelperClasses and the end resulting
    "WorkSheets" (back into technish). Line of code wise this is maybe
    80/4000 if you don't count the Boids (another 4,000 and growing
    rapidly).

    .....just for some perspective.
     
    thunk, Mar 27, 2010
    #4
  5. thunk

    thunk Guest

    Re: Class of the calling Object, is there someway to fetch it (fromthe called method)?

    OK!

    SUMMARY
    I have been to the mountain top and gotten this from a Ruby Guru -
    there are two ways of getting at the class but one way is a hack, and
    not a pretty one, or even what appears to be a reliable one. And the
    2nd way, using binding, seems to require a param - which is what I was
    trying avoid.

    RAMBLINGS
    Since I've become totally stuck on this "keyLess entry" for now, at
    least to play with for awhile, I have decided to do something a little
    strange - I'm going to require that all the method names in all the
    involved sending libraries are unique - a non-unique new method will
    just need a tweak and the whole system can work on the method name
    alone as the key. A nice friendly message will come up and tell a
    contributing writer that his carefully thought out name needs to get
    tweaked - or I could append a tie breaker to it - and just give it to
    him.

    LINK TO A GIST - It might have some use for somebody with enough
    changes, it sure has been interesting to play with.

    http://gist.github.com/345646
     
    thunk, Mar 27, 2010
    #5
  6. thunk

    Ryan Davis Guest

    Re: Class of the calling Object, is there someway to fetch it (from the called method)?

    On Mar 26, 2010, at 20:10 , thunk wrote:

    > 1. I don't know from "tuples" - all I "need" are hashes. Somebody
    > also mentioned Graphs. I'm happy with my set of conventions and these
    > hashes for my purposes.


    > 2. I looked at Rinda and didn't understand it.


    > ... and the rest


    DTM

    you flipped the bozo bit.
     
    Ryan Davis, Mar 27, 2010
    #6
  7. thunk

    thunk Guest

    Re: Class of the calling Object, is there someway to fetch it (fromthe called method)?

    On Mar 27, 4:14 am, Ryan Davis <> wrote:
    > On Mar 26, 2010, at 20:10 , thunk wrote:
    >
    > > 1.  I don't know from "tuples" - all I "need" are hashes.   Somebody
    > > also mentioned Graphs.  I'm happy with my set of conventions and these
    > > hashes for my purposes.
    > > 2. I looked at Rinda and didn't understand it.
    > > ... and the rest

    >
    > DTM
    >
    > you flipped the bozo bit.
     
    thunk, Mar 27, 2010
    #7
  8. thunk

    thunk Guest

    Re: Class of the calling Object, is there someway to fetch it (fromthe called method)?

    On Mar 27, 4:14 am, Ryan Davis <> wrote:
    > On Mar 26, 2010, at 20:10 , thunk wrote:
    >
    > > 1.  I don't know from "tuples" - all I "need" are hashes.   Somebody
    > > also mentioned Graphs.  I'm happy with my set of conventions and these
    > > hashes for my purposes.
    > > 2. I looked at Rinda and didn't understand it.
    > > ... and the rest

    >
    > DTM
    >
    > you flipped the bozo bit.



    Are you really trying to tell me I "need" a tuples Gem with no (found)
    documentation, to replace my 80 line class that does what I need?

    You can tell me that rather than use something I'm comfortable, wrote
    100% myself, I should use a Gem from folks I don't know, with overhead
    I don't know, with quality issues I have no way to estimate, and
    support I can only guess at, to do something I haven't a clue why I
    would need?

    My first app generated apps as a R&D manager for McGraw-Hill back in
    1984. Since then my apps have done what I designed them to do, and I
    have never failed to finish a project I started. I have delivered,
    documented, and supported FIVE large scale commercial projects, how
    many have you?

    (They happened to have been in the field of STATISTICAL PROCESS
    CONTROL - we trained folks at HP, John Deere, Mercury Marine and other
    corps on how to use this software. My reseller were the two largest
    precision tool manufacturers in the World - Mitutoyo and Brown &
    Sharpe.)

    So do you really think you invented Testing and have a patient on it
    or something?



    Thunk
     
    thunk, Mar 27, 2010
    #8
  9. thunk

    thunk Guest

    Re: Class of the calling Object, is there someway to fetch it (fromthe called method)?

    Ryan,


    I'm a "step-wise-refinement" guy. it worked for me for many years, and
    I think I can make a good case for it against any other kind of
    development, when and where it can be used. There's more to it than
    one might think, it is a way to follow one's instincts and work to
    strengths and let the code show you where to go next.

    Some folks will understand that, some won't. If you don't, I suspect
    you are missing some of the real joy of programming.

    Or maybe you think it is all science?


    Thunk
     
    thunk, Mar 27, 2010
    #9
    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. DeWitt Phillips
    Replies:
    2
    Views:
    345
    Joe Gass
    Dec 12, 2003
  2. jklioe
    Replies:
    0
    Views:
    589
    jklioe
    Oct 31, 2006
  3. Francesco Moi

    Is there any library to get/fetch a remote URL?

    Francesco Moi, Oct 5, 2004, in forum: C Programming
    Replies:
    13
    Views:
    466
    Mark McIntyre
    Oct 6, 2004
  4. Tinku
    Replies:
    3
    Views:
    1,223
    Alf P. Steinbach
    Jan 31, 2010
  5. why-em-jay

    Calling a method of the calling object ...

    why-em-jay, Sep 15, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    197
    Anno Siegel
    Sep 15, 2005
Loading...

Share This Page