Re: [Pyobjc-dev] Auto bridging instances by conversion
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2003-02-03 18:38:40
|
On Monday, Feb 3, 2003, at 11:21 America/New_York, Ronald Oussoren wrote: > > On Monday, Feb 3, 2003, at 16:58 Europe/Amsterdam, Bob Ippolito wrote: > >> >> On Monday, Feb 3, 2003, at 10:30 America/New_York, Just van Rossum >> wrote: >> >>> bb...@ma... wrote: >>> >>>> The fact that NSString<->PyString are converted is a bug -- >>> >>> To me it isn't, it's what I call "transparent". This feature is >>> absolutely a _pleasure_ to work with. >> >> It's what I call a "real pain in the ass", at least when >> NSMutableString gets bridged into a PyString. > A real argument for not doing the conversion! > > Not converting can also be problematic: What if you pass the NSString > to an extension-function that expects a string (like open), unless > these get changed to also accept NSStrings you'll have to perform > manual conversion from NSString to a python string. Say NSString acts like 100% like UserString (i.e. implements __str__ and such), wouldn't PyArg_ParseTuple(AndKeywords) do The Right Thing? >> >> Why can't we wrap the NSString class cluster with some cruft that >> makes it pythonic instead of converting it to something that it >> wasn't? There is absolutely no namespace clash between NSString and >> PyString, with the added bonus that NSString can do just about >> everything that PyString can with one line of code or less. > > The 'problem' with NSString is that its interface is much more > powerfull than that of python strings (the word cruft springs to mind > when seeing methods like stringByAbbreviatingWithTildeInPath). Well since there is no namespace clash, NSString doesn't lose those. If PyArg_ParseTuple does The Right Thing, this (useless code) should work: myDesktop = NSString('~/Desktop').stringByAbbreviatingWithTildeInPath() myHomedir, myDesktop = os.path.split(myDesktop) > > In case anyone cares: I (still) haven't made made my mind up on > whether automaticly converting values is a usefull feature or not. > There are to many irritating 'features' on either solution (converting > or wrapping). I'm really against converting NSMutableANYTHING. I can think of at least one AppKit class where you can get a NSMutableString (perhaps it's a subclass of) as an rval to some method, where you change that NSMutableString and the view changes its contents based upon any changes you make to that NSMutableString (without having to call any additional methods). -bob |