[Pyobjc-dev] Default to returning (void)?
Brought to you by:
ronaldoussoren
From: b.bum <bb...@ma...> - 2004-02-16 03:41:50
|
This is going to break a few things, but better to rip off the band-aid now than wait.... Currently, if I declare a standard IB action or set method (such as the following).... def setContent_(self, someContent): print "Setting content...." self._content = someContent .... I have to immediately follow the declaration with the following ... setContent_ = selector(setContent_, signature='v@:@') ... if I wait the method to be compatible with Key/Value Observation or otherwise match the signature of the typical setter or IBAction. When PyObjC was originally written -- 1994 or so -- the NeXTSTEP standard was for Obj-C methods to default to returning (id) -- to end with 'return self;'. The goal was to support a Lisp Like method chaining of the [foo doBar] doBaz] doBob] sayFred] form. When OpenStep rolled around, the ObjC world shifted to methods defaulting to not returning anything. That is, to be declared as returning (void). This has many advantages for very little cost. In particular, it means that remote invocation models-- cross thread or inter-process-- can actually do one-way calls without having to carry a proxy back across the wire. It also means that apps didn't explode because a developer assumes 'return self' when a method really returns something else (something that happened a number of times!). Of course, with Python we have no notion of "return type". A method may or may not return anything. Right now, PyObjC assumes a return of (id). In ObjC parlance, the assumed signature prefix is '@@:'. Is there any way that we can make it a bit more natural for the developer to declare IBActions or setters in PyObjC such that the resulting methods have signature 'v@:@'? |