[Pythonmac-SIG] "All I want..." [was: IDE feature requests]

Bill Bumgarner bbum@codefab.com
Sun, 19 Nov 2000 14:32:51 -0500 (EST)


On Sun, 19 Nov 2000, Steven D. Majewski wrote:
>  BTW to Bill: Is there a way to produce the nil object ? I don't
>  see it available as a constant and methods that should return nil
>  seem to produce Python None. Is the runtime smart enough to convert
>  None to nil in the other direction ? 

nil is equivalent to NULL in Objective-C.   I.e. it isn't really an object, just
a fancy name for the address 0x00000 for portabiities sake.  Who knows;  maybe
some day we will run into a system that defines 0xBEEFFACE as Null/nil.

However, one key difference in ObjC is that [foo anyMethod] where (foo == nil)
is, effectively, a no-op.  As long as anyMethod is declared as returning a
pointer type return value, such an invocation will always evalauate to nil.   In
the case of float or structure-on-stack returns, the return value is undefined.

I'm not necessarily sure I ever agreed with that particular design decision, but
it has been convenient *at times* (it has also led to many a wasted hour at
other times).

The Python<->ObjC bridge *should* be smart enough to deal with converting
nil->None and None->nil.  However, I haven't explicitly tested it.

 
>  Also: This snapshot seems to have also fixed errors in using python
>  array indexing on NSArray's. The following used to crash on me.
>  Bill -- did you fix something here when you fixed the autorelease
>  pool, or is this another side effect of finally getting it to link
>  properly?

I can't imagine a side effect of the linking process that would have fixed this
problem.  However, I did diddle with the handling of object references
*slightly* to fix the Autoreleasepool problem.   I can't imagine how that would
have changed things.  

I'm glad to see this is now working even if it is disturbing that it would
magically start working again.

The sourceforge account is stil broken; they screwed up the cvs configuration by
leaving the history file unwritable by group.   So far, I'm not impressed by
SF's handling of a basic acocunt creation.

b.bum
 
> >>> from ObjC import *
> >>> P = runtime.NSAutoreleasePool()
> >>> P
> <Objective-C `NSAutoreleasePool' instance at 229c20>
> >>> all = runtime.NSBundle.allFrameworks()
> >>> all
> <Objective-C `NSCFArray' instance at 22b110>
> >>> print all
> (
>     NSBundle </System/Library/Frameworks/Foundation.framework> (loaded), 
>     NSBundle </System/Library/Frameworks/AppKit.framework> (loaded), 
>     NSBundle </usr/local/lib/python2.0/lib-dynload> (loaded), 
>     NSBundle </usr/lib> (loaded)
> )
> >>> all[0]			# This array access used to crash me! 
> <Objective-C `NSBundle' instance at 232340>
> >>> for x in all : print x	# not to mention this!
> ... 
> NSBundle </System/Library/Frameworks/Foundation.framework> (loaded)
> NSBundle </System/Library/Frameworks/AppKit.framework> (loaded)
> NSBundle </usr/local/lib/python2.0/lib-dynload> (loaded)
> NSBundle </usr/lib> (loaded)
> >>> 
> 
>  
> 
> ---|  Steven D. Majewski   (804-982-0831)  <sdm7g@Virginia.EDU>  |---
> ---|  Department of Molecular Physiology and Biological Physics  |---
> ---|  University of Virginia             Health Sciences Center  |---
> ---|  P.O. Box 10011            Charlottesville, VA  22906-0011  |---
> 		"All operating systems want to be unix, 
> 		 All programming languages want to be lisp." 
> 
>