Re: [Pyobjc-dev] Why syntax?
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2001-04-12 21:11:13
|
Because the mangling that is done now is really easy-- simply substitute : for _ -- whereas the second form is considerably harder. One key difference between Java and ObjC is that ObjC doesn't require us to know the method signatures-- the names-- prior to actually invoking the method. We can effectively "catch" the request for a particular method the first time an execution is attempted, and generate the ObJC name of the method at that point in time. It is 100% dynamic and all at runtime; there is no need for any prior knowledge regarding the existence of a method or class. Jython-- on the other hand-- must compile the Python classes into JVM byte code prior to even loading the class, much less executing a method. That is, every method that is to be executed must be compiled into the JVM byte code stream prior to loading the class. A secondary problem is that key/value arguments are not ordered. I.e. Ignoring for a moment that "win.init(contentRect=frame, styleMask=15, backing=2, defer=0)" drops the "With", the order with which the key/value arguments are passed to the init() function cannot be known. As such, it makes reconstructing the method really hard; nearly impossible. This was actually discussed at great length in '96 or '97 when Lele, myself and others were actively working on the ObjC module. We determined then that the amount of work did not justify the small reward. b.bum On Thursday, April 12, 2001, at 04:11 PM, Andrew Zeldis wrote: > This is probably a dumb question, but there isn't much of an archive on > this topic (since there's really only been two people posting...) > > Why does PyObjC mangle method names, instead of using named > parameters? I understand why it's done that way for the Java bridge - > Java is an inferior language. But why for Python? I'd like to see: > > win.initWithContentRect_styleMask_backing_defer_ (frame, 15, 2, 0) > > become > > win.init(contentRect=frame, styleMask=15, backing=2, defer=0) > > If you've looked at Jython, it does a lot to "pythonify" java methods > and classes - it lets you specify thing that look like bean properties > in constructors, for instance, and makes things that look like > properties available as attributes. It would be nice to do similar > things for the PyObjC module, to make it as Pythonic as possible... > > This seems really obvious, however, so I'm sure there's a reason why it > hasn't been done. Please enlighten. > > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > http://lists.sourceforge.net/lists/listinfo/pyobjc-dev |