[Pyobjc-dev] Re: [Pythonmac-SIG] pyobjc / cocoa

bbum@mac.com bbum@mac.com
Wed, 16 Oct 2002 18:15:52 -0400


On Wednesday, October 16, 2002, at 06:10 PM, Bob Ippolito wrote:
> It's not.  Though, I can see how it'd be kinda useful in strange cases 
> to have the "rt.call" function around.

Definitely useful!

In particular, if we had an objc_msgSend() equivalent available on the 
Python side of the bridge, it opens things up for some truly tremendous 
opportunities.

(If you know ahead of time the type and number of arguments -- which 
you would given that the call is coming from Python -- then 
NSInvocation can be used to build a stack frame and, as such, could be 
used to implement a solution -- slightly inefficient, but a solution 
none-the-less)

With objc_msgSend() around, you could do something like...

     objc.msgSend(Foundation.NSString, "stringWithFormat:", "Foo %d Bar 
%5.3f Baz %s", 10, 25.3, "bob")

That is, you could call the handful of varargs methods in the various 
'kits.

But, more importantly, it means that you could programmatically 
dispatch methods from the python side using standard idioms -- 
something that *can* be done now, but not without a bit of pain.

b.bum