Objective-Everything Release 5.  Copyright ©1994-1998 by TipTop Software, Inc.  All Rights Reserved.

  Postscript

Tips

Forcing superclass autoloading.  When defining a class in ObjTcl, one way to make sure that the superclass is defined is to use:

 class MyClass [OtherClass] ... 

instead of:

 class MyClass OtherClass ... 

If OtherClass is already defined, evaluating OtherClass will simply return OtherClass.  If OtherClass is not defined, the ObjTcl autoloading mechanism will attempt to load the class definition from the appropriate (compiled or interpreted) file, and, if successful, OtherClass will be returned.

Dynamically loading libraries.  If you have a class library (libYourLib.dylib) or a Mach-O relocatable (bundle) format file (YourLib.so, YourLib.bundle) that you want to use from objtclsh you can dynamically load it. Simply do:

 % objtcl::dyload YourLib.so 

To build a relocatable object file from a static library:

 cc -bundle -undefined suppress -o YourLib.so -all_load libYourLib.a 

To build a relocatable object file from your object files a.o, b.o, and c.o:

cc -bundle -undefined suppress -o YourLib.so -all_load a.o b.o c.o

Minimal OB.  Here is how you can invoke OB on the default ObjTcl interpreter object from objtclsh:

 appkit::run { 
browse $interp
}

Caveats

Retain/release.  Objective-Tcl takes care of automatically retaining and releasing objects for you:

As a consequence of this you rarely ever have to be concerned about retain/release.  The following are the cases when you do have to take to explicitly handle retain/release:

 method -(void)setDelegate:(id)d { 
   $myDelegate retain 
   set myDelegate $d 
   $myDelegate release 
 } 

Instance variable access within procedures invoked from a method body.  Recall that $self and $_cmd are defined within a method body.  The following two commands are equivalent, when invoked in a method body, provided that ivar is an instance variable defined for the receiving object:

 set ivar $val 
 ivarset $self ivar $val 

The first form implicitly relies on $self being defined.  Now, consider:

 class MyObject NSObject { 
   id anObj; 
 } { 
   method -(void)setObj:o { set anObj $o } 
   method -(void)setObjUsingProc:o { setproc anObj $o } 
 }
proc setproc {ivar val} { 
  upvar $ivar v 
  set v $val 
} 
 set o [MyObject object] 

Doing:

 $o setObjUsingProc: [NSObject] 

Does not set anObj because $self is not defined within the setproc procedure!

Known Problems


[previous][contents][next]