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

T

thunk

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
 
R

Ryan Davis

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

thunk

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

thunk

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

thunk

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
 
T

thunk

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
 
T

thunk

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
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top