Re: hierarchical packaging (was: Java API)

Ralf Juengling <[email protected]> Mon, 13 Feb 2006 12:31:50 -0800 (PST)
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
On Sun, 12 Feb 2006, Raymond Martin wrote:
>
> On another note, I have come across an implementation of hierarchical packaging
> for CL like what is used in java.
>
> What about something similar in Lush?
>
> Maybe wrapping libload in some way so that it can provide something more like java/python
> for those who want it:
>
> (import lush.standard.compat) -> (libload "compat.lsh")
>
> (import lush.packages.alsa) -> (libload "alsa")
>
> (import net.sf.lush.ogre.helptool) -> (libload "libogre/helptool.lsh")

If this more than an abstraction from lush's directory structure, then
I don't get the idea (please elaborate).


To add my few cents, I think Python's way of organizing namespaces into
modules is very desirable (I don't know Java).
In Python a "module" (think of it as one source file) defines a "context"
for all the functions and classes defined therein. This context typically
consists of constants and helper functions. When you call a function, it
is evaluated in the context of its module. You are free to override 
a global definition/binding in a module context--this won't change the
global definition/binding unless you explicitly "import" it into the
global namespace (see below). The "global definition/binding" is the
definition/binding existing in the module containing the import
statement.

For instance, you may have written some code interspersed with print
statements for debugging purposes. To turn these print statements of,
you could write something like  (defmacro print args `())  at the
beginning of the module.

To "explicitly import" something from a module, you have to specify the
name(s) of the thing(s) you want to import. For instance, if you only
need the functions 'read-lines' and 'write-lines' from module
'libc/shell', your import statement would look like

(import (read-lines write-lines) from "libc/shell")

Ralf


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642