Lisp HUG Maillist Archive

Delivery question

I'm new to delivery of applications for LispWorks, so sorry if this seems like a silly question...

When my app uses several other packages, I'm finding myself "hacking" the delivery process to get it to work. Let me give a simple example, and perhaps that will help explain. I'm hoping someone can clue me in and let me know how to do what I want better. ;-)

;;; file MyPackage.lisp

(defpackage :my-package ...)
;; ...
(provide "MY-PACKAGE")



;;; file MyProgram.lisp

(use-package :my-package)
;; ...



Now, to-date, this has been fine for me since I've only been using the listener. I open my package, compile, open my program, compile, test away, and the world is good. However, when using delivery to compile, it fails:

(compile-file "mypackage.lisp" :load t)
(compile-file "myprogram.lisp" :load t)


It dies because myprogram.lisp shadows symbols declared in mypackage.lisp. I believe this is happening because when I compile the file in the editor, it's basically a glorified REPL (meaning it reads each expression one at a time), while COMPILE-FILE probably reads the entire file in one shot, then attempts to compile it. Because of this, my USE-PACKAGE call at the start of myprogram.lisp doesn't actually eval until *after* all the symbols have been interned. But that's just a guess right now.

My "hack" so far to get around this has been to insert (use-package :my-package) in between the calls to COMPILE-FILE in the delivery script. This works, but it feels like an unnecessary workaround due to my own ignorance right now.

Can anyone shed some light on what I should be doing?

Thanks!

Jeff M.

Re: Delivery question


Am 03.10.2008 um 18:33 schrieb Jeff Massung:

> I'm new to delivery of applications for LispWorks, so sorry if this  
> seems like a silly question...
>
> When my app uses several other packages, I'm finding myself  
> "hacking" the delivery process to get it to work. Let me give a  
> simple example, and perhaps that will help explain. I'm hoping  
> someone can clue me in and let me know how to do what I want  
> better. ;-)
>
> ;;; file MyPackage.lisp
>
> (defpackage :my-package ...)
> ;; ...
> (provide "MY-PACKAGE")
>
>
>
> ;;; file MyProgram.lisp
>
> (use-package :my-package)
> ;; ...
>
>
>
> Now, to-date, this has been fine for me since I've only been using  
> the listener. I open my package, compile, open my program, compile,  
> test away, and the world is good. However, when using delivery to  
> compile, it fails:
>
> (compile-file "mypackage.lisp" :load t)
> (compile-file "myprogram.lisp" :load t)
>
>
> It dies because myprogram.lisp shadows symbols declared in  
> mypackage.lisp. I believe this is happening because when I compile  
> the file in the editor, it's basically a glorified REPL (meaning it  
> reads each expression one at a time), while COMPILE-FILE probably  
> reads the entire file in one shot, then attempts to compile it.

No, it will read the file form by form.

> Because of this, my USE-PACKAGE call at the start of myprogram.lisp  
> doesn't actually eval until *after* all the symbols have been  
> interned. But that's just a guess right now.
>
> My "hack" so far to get around this has been to insert (use- 
> package :my-package) in between the calls to COMPILE-FILE in the  
> delivery script. This works, but it feels like an unnecessary  
> workaround due to my own ignorance right now.
>
> Can anyone shed some light on what I should be doing?

Let me have a guess...

The Lisp compiler sees the forms, but it only compiles them - it does  
not execute them - usually. So, if you have a form
in the file that the compiler should execute, you need to tell the  
compiler to do so. EVAL-WHEN does that.

(eval-when (:compile-toplevel :load-toplevel :execute)
    (use-package :my-package))

Above tells the compiler to execute the form. You might also want to  
tell which package should use :my-package.
USE-PACKAGE uses as default the value of *package*:

   (use-package :my-package :my-other-package)

Regards,

Rainer Joswig


>
> Thanks!
>
> Jeff M.

Rainer Joswig, Hamburg, Germany
http://lispm.dyndns.org/
mailto:joswig@lisp.de




Updated at: 2020-12-10 08:42 UTC