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

Bob Ippolito bob@mastersofbranding.com
Wed, 16 Oct 2002 17:27:03 -0400


On Wednesday, Oct 16, 2002, at 16:20 America/New_York, Bob Savage wrote:

>
> On Wednesday, October 16, 2002, at 01:54 PM, Seth Delackner wrote:
>
>> On Wednesday, October 16, 2002, at 06:18 , Bob Savage wrote:
>>
>>> [obj message: arg1 withFoo: arg2];
>>> [obj withFoo:arg2 message:arg1];
>>>
>>> Those are two different methods. This means that the Seth's system 
>>> would not work
>
>> I may be wrong, but I disagree with your assessment.  There is only a 
>> single mapping possible from my example (although now looking at it, 
>> my example had a typo).  What I meant is:
>>
>> rt.call(obj, "message", arg1, "arg2name", arg2);
>> # giving us the message name = "message:arg1name:arg2name"
>>
>> The method 'rt.call' would take arguments  [0] object to receive the 
>> message, [1] first part of the message name, [2] .  Each subsequent 
>> pair of arguments is interpreted as first the next chunk of the 
>> message name and then the next part of the message arguments.
>>
>> Where is the ambiguity?
>
> Hopefully I am not misunderstanding you. If what you are saying is you 
> could take :
>   rt.call(obj, "message", arg1, "arg2name", arg2);
> and have rt.call() concatenate the strings  "message" and "arg2name" 
> (with a colon between) then converting that to  the selector (like 
> method name for the runtime) "@sel(message: arg2name)" and then do a 
> call selector with arg1 and arg2, sure you can do that.
>
> Here is where I see the ambiguity arising:
>
> @sel is drawSelfAtPoint:withSize:color:
>
> rt.call(obj, "drawSelfAtPoint", p, "color", c, "withSize", "s")
>
> rt.call() concatenates the method name as "drawSelfAtPoint: color: 
> withSize:". Then the runtime sends a message to the object to perform 
> the selector "@sel (drawSelfAtPoint: color: withSize:)", and the 
> object says, it can't.
>
> Am I understanding you correctly? Because, the way I see it, this is 
> likely to encourage runtime errors (unknown selector).

That's not a case of ambiguity, that's just Programmer Error.  Unknown 
selector is what they *should* get for issuing the selectors in an 
incorrect order.  Notice that he's using ordered list arguments, not 
dictionary arguments for his call function.

-bob