[Xotcl] Re: XOTcl is great!!

Gustaf Neumann neumann at wu-wien.ac.at
Thu Sep 8 10:37:48 CEST 2005

Kristoffer Lawson schrieb:

> I was thinking about using packages to collect classes together. 

i have started some work towards turning packages into objects, where a 
is an instance of a class Package. This allows in general to
 - query which packages are loaded in which versions
 - easy means to query the content and dependencies btw. packages
   (package-relations,  could be graphically presented)
 - provide unloading (with destructors) of packages  
 - allow for nested packages
 - since packages are instances that export stuff, it could be in 
pinciple possible
   to load multiple versions of a package simultiously, where one is not 
required to
   base everything on the same version of the package.

Although i have a few pieces for this already working, this won't make 
it into the next release.
Andreas Kupries from active state has done some great work to make the 
xotcl libraries
namespace clean, there is still some more work to get everything running 
again, and
this is an important step towards the above. The namespace clean 
libraries are inteneded
to be in the next release.

> The  problem with this is that classes are not automatically searched 
> for  in the same package. That is if Class A depends on Class B (A is 
> B's  sub-class), B needs to be read in before A is read.  In Java it 
> is  enough that they are in the same package, they'll be found. With  
> XOTcl you need to build a kind of stub file that represents the  
> package and which then sources in all the other necessary files in  
> the required order.

a few remarks to this:
 - what's wrong with "package req package-providing-class-B" in the 
package containing class A?
   this is the natural tcl style for such issues.
 - if you need more fine-grained control, xotcl provides in additon the 
__unknown method
   (which should be called actually  "undefined class reference"). 
Zoran's ttrace package
   (part of the tcl thread library) uses this. see below for a short 
example for __unknown ...


  Class proc __unknown args {
    # called upon unresolvable Class names; here one can use e.g. an
    # index to load classes from source files or from serialized
    # definitions
    set r [Class create $args]
    puts "... class $r created on the fly ..."
    return $r

  Class B -superclass A

More information about the Xotcl mailing list