Re: [Pyobjc-dev] Question about method name mangling
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-05-08 10:13:16
|
Jack Jansen wrote: > > In "Writing the Code - Step 8." we explain after the fact that we > > won't be doing the name mangling. This seems awkward. Since the > > code works with the name mangling, is there any reason not to go > > ahead with it? There's no reason to do the mangling, so why bother? > > class Converter(NibClassBuilder.AutoBaseClass): > > # the actual base class is NSObject > > > > def convertAmount_atRate_(self, amt, rate): > > return amt * rate > > > > Other than that, the tutorial is excellent! Kudos to all involved. > > I explicitly didn't do name mangling here to explain this point: that > you don't have to use it your method is only going to be used from > Python. > > But if more people feel that this is obscure I can take it out... I think it's a important point to make. The mangling is only needed when calling ObjC methods or when ObjC is going to call Python methods. For all other stuff it's best to follow Python conventions. It's not that the name mangling makes things _better_ on the Python side, it's a neccesary evil to be able to bridge to ObjC. I quite like this example: sp.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_( None, None, self.glyphView.window(), self, "savePanelDidEnd:returnCode:contextInfo:", 0) I'm definetely not going to name a method like that if it's never intended to be called from ObjC ;-) Just |