Re: package frenzy



Joris Bleys wrote:
Hello all!

I'm experiencing some problems using packages in Lisp and I'm wondering what your opinions are about the packages-facility in Lisp. I've been hearing around and most of my comrades suggest not to use packages. I'd like to use them to avoid nasty things like name-clashes (that's what they're for, right?). Is there any guide on how packages should be used?

No, you absolutely should use packages. Programming in the CL-USER package means your code cannot be integrated with others who do the same, and is possibly nonportable anyway since implementations can stick any symbols they want in that package.

I typically make the packages fairly large, and put their definitions
off in their own files, but this is style.

It's a good idea to avoid using the :: package prefixes when possible.
That's a sign that someone is cheating and going behind the back
of a package's public interface.


Let's say I have some package :exporting-package, which has two functions: ep-internal-fn and ep-external-fn. The ep-internal-fn gets a string as argument and returns a symbol using (read-line str NIL NIL). The ep-external-fn uses eq to compare the result of ep-internal-fn with a pre-programmed symbol 'TEST. The ep-external-fn is exported.

Now another package is defined :importing-package which uses the :exporting-package (use-package). When ep-external-fn is called, the equality is always false. This happens because the result of ep-external-fn is a symbol in the package :importing-package, whereas the 'TEST symbol is defined in the :exporting-package.

That symbol was part of the API of the exported function, so it itself should have been exported also. Or, you could have used a keyword symbol.

(Also be careful when calling READ-LINE that you've bound *PACKAGE*
appropriately.)

	Paul
.



Relevant Pages

  • Re: Why Lisp is too hard for me to use
    ... Lisps and several libraries. ... so it needs implementation support. ... The current strong support for Lisp ... > This consists of simple .tar.gz packages, ...
    (comp.lang.lisp)
  • Re: CLOS usage patterns?
    ... Nick Lacey writes: ... In Lisp the smallest things these ... Maybe your problem is that you are not creating enough packages, ... > doesn't take the public/private distinction as seriously as Java. ...
    (comp.lang.lisp)
  • Re: A problem statement (and a proposed solution)
    ... that there is progress in the language. ... Lisp in a box does not exist. ... handful packages included. ... Lisp is so special that you don't need to use libraries written by others. ...
    (comp.lang.lisp)
  • Re: Generate plots with lisp
    ... would like the same code to generate a drawing. ... get to learn a bit more lisp. ... packages. ... I did manage to install and load asdf, and likewise for cl-pdf. ...
    (comp.lang.lisp)
  • Re: Troll-o-Matic
    ... controversial questions regarding the Lisp programming language. ... This document is written in the hope that it will improve trolling ... packages for things like the web, threads, regular expressions or OS ... or real elitism in lispnik circles. ...
    (comp.lang.lisp)