On Jun 21, 2006, at 6:47 PM, [EMAIL PROTECTED] wrote:
On Jun 21, 2006, at 22:18 UTC, Mike Woodworth wrote:
well, this seems to kinda work as is... except for the parts that
don't work at all :) my early tests with simple things like beep
seemed fine, but now that im doing stuff that relies on instance
properties in the callback - it appears i'm not really in the
instance at callback time??
Of course you're not. How would whatever's calling this callback
method know to pass in the magic parameter that gets mapped to 'self'?
That's the whole point about instance methods, and why Mars said
that you couldn't do anything useful with them -- an instance
method, in any language, involves passing along some extra
information that identifies the instance. There is no way for you
to know (because it's not documented) what form this information
takes, so there is certainly no reliable way for whatever's
invoking the callback to know that and do it properly.
all this makes sense *if* you know how things work under the hood. i
wouldn't be surprised to find i'm sort of a strange user, in that i
do a lot of power RB stuff, declares, etc, but have no language
background outside rb... much less any comp sci background. spend
enough time in something as oopy as RB, you start to believe that
object are discreet things all the way down to individual function ptrs.
it appears that the callback is calling the instance method as if it
were a shared method?
It's calling it as if it is a function pointer, since that's all it
is. It doesn't know anything more about it. Play around with
invoking instance methods that way, without the extra info they
need, and I would expect your app to crash. Kinda neat to hear
that maybe it doesn't in your case, but I certainly wouldn't rely
on that.
it appears you can call instance methods as long as they don't need
to ref self.
do all class instances share the same function ptr?
then some magic is done to ref the right properties at call time?
Yes, the magic is in the extra info which gets passed in any proper
call to an instance method.
makes sense... so where would one learn about all such fun
underpinnings of oop (and specifically rb) without going through the
trouble and expense of flunking out of college again?
mike
--
Mike Woodworth
[EMAIL PROTECTED]
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>