Lisp HUG Maillist Archive

Why is constant qualified with package name in delivered exe?

I have two files which both have symbols and functions in the same 
package. When I deliver and then execute, when a constant in one file is 
accessed by a function in the other, it is qualified by the package 
name.  Since they are both in the same package, I don't understand why 
that would be.  Thanks for any help.

;;; -----------------------------------
;;; File: deliver-hello.lisp

(in-package "CL-USER")
(load-all-patches)
(compile-file "goodbye-world.lisp" :load t)
(compile-file "hello-world" :load t)
(deliver 'hello::hello-world
          "d:/grouptix/hello"
          0
          :interface :capi)

;;; -----------------------------------
;;; File: goodbye-world.lisp

(in-package "CL-USER")

(defpackage :hello
   (:use :common-lisp)
   (:add-use-defaults t))

(in-package :hello)

(defconstant +goodbye-symbol+ 'goodbye)


;;; -----------------------------------
;;; File: hello-world.lisp

(in-package :hello)

(defun hello-world ()
   (capi:display-message (format nil "~s" +goodbye-symbol+)))

;;; -----------------------------------

At the prompt:
 > "c:\program files\lispworks\lispworks-5-1-0-x86-win32.exe" -build de
liver-hello.lisp > hello-log.txt

and when I run hello.exe, I see HELLO::GOODBYE in the CAPI message box 
instead of just GOODBYE.

I thought that changing deliver-hello.lisp to something like the 
following would make a difference, but it doesn't.

;;; -----------------------------------
;;; File: deliver-hello.lisp alternate version

(in-package "CL-USER")
(load-all-patches)
(compile-file "goodbye-world.lisp" :load t)
(compile-file "hello-world" :load t)
(in-package :hello)
(deliver 'hello-world
          "d:/grouptix/hello"
          0
          :interface :capi)


Re: Why is constant qualified with package name in delivered exe?


Am 13.11.2008 um 16:49 schrieb Mitch Berkson:

>
> I have two files which both have symbols and functions in the same  
> package. When I deliver and then execute, when a constant in one  
> file is accessed by a function in the other, it is qualified by the  
> package name.  Since they are both in the same package, I don't  
> understand why that would be.  Thanks for any help.
>
> ;;; -----------------------------------
> ;;; File: deliver-hello.lisp
>
> (in-package "CL-USER")
> (load-all-patches)
> (compile-file "goodbye-world.lisp" :load t)
> (compile-file "hello-world" :load t)
> (deliver 'hello::hello-world
>         "d:/grouptix/hello"
>         0
>         :interface :capi)
>
> ;;; -----------------------------------
> ;;; File: goodbye-world.lisp
>
> (in-package "CL-USER")
>
> (defpackage :hello
>  (:use :common-lisp)
>  (:add-use-defaults t))
>
> (in-package :hello)
>
> (defconstant +goodbye-symbol+ 'goodbye)
>
>
> ;;; -----------------------------------
> ;;; File: hello-world.lisp
>
> (in-package :hello)
>
> (defun hello-world ()
>  (capi:display-message (format nil "~s" +goodbye-symbol+)))
>
> ;;; -----------------------------------
>
> At the prompt:
> > "c:\program files\lispworks\lispworks-5-1-0-x86-win32.exe" -build de
> liver-hello.lisp > hello-log.txt
>
> and when I run hello.exe, I see HELLO::GOODBYE in the CAPI message  
> box instead of just GOODBYE.
>
> I thought that changing deliver-hello.lisp to something like the  
> following would make a difference, but it doesn't.

So it seems that when the program starts then "HELLO" is not the  
default package. You set LispWorks to this
package when you are delivering the application. But that does not  
automatically make
that package the default package at runtime.
Look at the value of *package* at runtime.

If your code at runtime depends on the default package, then you  
should set it at startup.

Regards,

Rainer Joswig


>
>
> ;;; -----------------------------------
> ;;; File: deliver-hello.lisp alternate version
>
> (in-package "CL-USER")
> (load-all-patches)
> (compile-file "goodbye-world.lisp" :load t)
> (compile-file "hello-world" :load t)
> (in-package :hello)
> (deliver 'hello-world
>         "d:/grouptix/hello"
>         0
>         :interface :capi)

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




Re: Why is constant qualified with package name in delivered exe?

On 13 Nov 2008, at 15:49, Mitch Berkson wrote:

>
> and when I run hello.exe, I see HELLO::GOODBYE in the CAPI message  
> box instead of just GOODBYE.

If you want to know the package you need to set it when the code runs,  
which is *not* the same as compile time, or any other time.

So you need your function to do something like

(let ((*package* ...))
   ...)

--tim


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