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

Re: CL packages

On Saturday, October 25, 2003, at 12:09 PM, Daniel Weinreb wrote:

Very briefly, the main problem with the Common Lisp package system is that it all
happens at "read time".

Thanks for your input. Here's an example of what I think you mean:

(defpackage "ONE" (:use "CL")
(:export #:one-a #:one-b))

(defpackage "TWO" (:use "CL" "ONE")
(:export #:two-a #:two-b))

;;;; do something in package one
(in-package one)

(defun one-c ()

;;;; do something in package two
(in-package two)

;;; whoopts, forgot that I hadn't exporte one-c yet
(defun two-c ()
==> ;Compiler warnings :
; Undefined function ONE-C, in TWO-C.

;;;; go back and fix package
;;; but one-c is now interned in "TWO"
(defpackage "ONE" (:use "CL")
(:export #:one-a #:one-b :one-c))
==> > Error in process Listener
> 1: Name conflict detected by EXPORT :
> EXPORT'ing ONE::ONE-C from #1=#<Package "ONE"> would cause a name conflict with
> the present symbol ONE-C in the package #<Package "TWO">, which uses #1#.

;;;; use restart to unintern two::one-c
;;; but all is not well. Trying
==> > Error in process Listener 1: Undefined function #:ONE-C called with arguments () .
> While executing: "Unknown"

;;;; uninterning two::one-c means that the function two-c now has the
;;; symbol #:one-c (one-c interned in no package) in it. I have to go
;;; and re-evaluate two-c for things to work.

(I'm sure that there are other "canonical" cases). But isn't part of the problem here in the development environment not the language? If my Lisp environment understood what I had done (and several other standard use cases), then instead of just uninterning, it could also re-evaluate two-c.

To put it differently, how much of CL's package problem is due to having a read-time? Are there other interactive languages with better solutions?
Gary Warren King, Lab Manager
EKSL East, University of Massachusetts * 413 577 0176

"Mankind must remember that peace is not Godís gift to his creatures; peace is our gift to each other."
-- Elie Wiesel, Nobel lecture, Oslo, Dec. 11, 1986