Re: hierarchical packaging (was: Java API)

Raymond Martin <[email protected]> Mon, 13 Feb 2006 22:01:20 +0000
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
Hi Ralf,

> >
> > [snip]
> > (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).
> 

Okay, I'll give it a shake...

Yes, it basically maps out to the directory structure.


> 
> To add my few cents, I think Python's way of organizing namespaces into
> modules is very desirable (I don't know Java).

I think that is similar to Java also.


> 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.

Scope definitely plays a part in the Java way of doing it, plus the use of packages
for context.

In Lush, I'm not sure going in that direction is really needed, although you can do
something like that via namespaces and packages in conjunction with the OOP
functionality. Can always refactor later for enhanced function.


> 
> 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")
> 

Well I have managed to write a simple function today to map from
(import libc.shell) to (libload "libc/shell") or
(import packages.alsa) to (libload "packages/alsa")

So everything as usually found on the Lush path will work.

To be able to load specific functions from file could be good in Lush, but I cannot 
see an overwhelming need to implement it. The use of an import statement is
just a convenient shorthand that just might also appeal to people coming to Lush
from Java, Python, or other language (the newLisp program has 'import' also).

Later.

Raymond

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



-------------------------------------------------------
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