[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] giving smalltalk python import

From: Robert Collins
Subject: [Help-smalltalk] giving smalltalk python import
Date: Wed, 08 Sep 2004 11:44:25 +1000

On Tue, 2004-09-07 at 13:54 +0200, Paolo Bonzini wrote:
> >I'd like to propose we do something similar:
> >PackageLoader import: 'gtk' !
> >should look along a defined search path for a directory called gtk
> >containing a predefined filename, and then fileIn: that filename.
> >
> That could be another packages.xml file.

It could be. There are some tradeoffs: its easier (and ease is
important) to just write a script, and be able to move it on disk to
have everything associated move, rather than have to create a formal xml

i.e. this might be a python file (the file is
what turns a directory into a package). Lets say this file is in a dir
import CVS #imports the file in this dir
import RCS #imports the file in this dir
this creates the following namespaces:
SCM  <- package
SCM.CVS  <- module
SCM.RCS  <- module

SCM has a user defined symbol defaultModule 
SCM.CVS has whatever was defined in

a smalltalkish version without xml might be:
PackageLoader import: 'CVS'; import: 'RCS' !
Namespace currentSpace at: #defaultModule put: CVS.abstractFactory !

to do the same with xml you need
==package.xml== (hand waving)
<dependent packages
  <relative path
  < fileIn: />
Namespace currentSpace at: #defaultModule put: CVS.abstractFactory !

which I think you'll agree is more work.

Now, there is no reason not to support both: but I don't see any value
in /requiring/ an xml file.

> >A default search path might be: the kernel directory
> >
> image directory


> >, ~/smalltalk-packages
> >
> how is this in python?

missing: folk tend to do something like:
export PYTHONPATH=~/mypackages
in their .bashrc or .profile

> >, /usr/share/gnu-smalltalk
> >
> the parent of the kernel directory


> >, /usr/share/gnu-smalltalk/site-packages
> >  
> >
> yes.
> There is already a search path in the PackageLoader for package.xml 
> files.  The idea would be like this:
> 1) if a package name includes a /, look for another packages.xml file in 
> a subdirectory (named like the package you are loading) of each 
> directory of the search path.  That is, loading blox-tk/Blox would look 
> for the Blox package into the packages.xml file of the blox-tk directory.

why not a . ? (I dont' have anything against '/', but . has some
* its the syntax used in the language to traverse namespaces
* its used in python (and possible other languages) for import

> 2) add site-packages etc. to the search path.
> 3) add a <namespace> tag to packages.xml that would automatically switch 
> the namespace before/after loading it.  This way (yahoo) most of the 
> loading scripts in the GNU Smalltalk would probably go away!

Thats still quite manual: I'd like to see the loader just Do The Right
Thing - do you think we could do that? (If we can conceptually do it,
then we can worry about how to get there :}).


GPG key available at: <>.

Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]