From: Karol Skocik
Subject: asdf unload-op ??
Date: 
Message-ID: <1153427454.624084.195400@m79g2000cwm.googlegroups.com>
Hi guys,
  when I work on my stuff, I sometimes need to unload the whole system
which is load-opped and reload it.  For example, I modify the asd file,
add some package in use list of defpackage and want to remove package
prefix in source, the only way I know now is to quit SBCL, delete
fasls, start SBCL and load-op again. Is there some better way? I saw
reset-cl-user function here by Pascal, can that be helpful in this
case? 
Thank you!

Karol

From: Pascal Bourguignon
Subject: Re: asdf unload-op ??
Date: 
Message-ID: <87zmf4m277.fsf@thalassa.informatimago.com>
"Karol Skocik" <············@gmail.com> writes:
>   when I work on my stuff, I sometimes need to unload the whole system
> which is load-opped and reload it.  For example, I modify the asd file,
> add some package in use list of defpackage and want to remove package
> prefix in source, the only way I know now is to quit SBCL, delete
> fasls, start SBCL and load-op again. Is there some better way? I saw
> reset-cl-user function here by Pascal, can that be helpful in this
> case? 


Indeed, the only way you have to "unload" a system, is to delete the
packages that were created by the system.  This is not perfect, there
may remain hooks or other references, which would keep some symbols in
these packages to be garbage collected, but at least, you couldn't
intern them again after delete-package.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Karol Skocik
Subject: Re: asdf unload-op ??
Date: 
Message-ID: <1153430765.492948.129250@i3g2000cwc.googlegroups.com>
all right, and what about if I unintern all symbols in package and then
delete-package? would this be enough to avoid this problems?

Karol

Pascal Bourguignon wrote:
> "Karol Skocik" <············@gmail.com> writes:
> >   when I work on my stuff, I sometimes need to unload the whole system
> > which is load-opped and reload it.  For example, I modify the asd file,
> > add some package in use list of defpackage and want to remove package
> > prefix in source, the only way I know now is to quit SBCL, delete
> > fasls, start SBCL and load-op again. Is there some better way? I saw
> > reset-cl-user function here by Pascal, can that be helpful in this
> > case?
>
>
> Indeed, the only way you have to "unload" a system, is to delete the
> packages that were created by the system.  This is not perfect, there
> may remain hooks or other references, which would keep some symbols in
> these packages to be garbage collected, but at least, you couldn't
> intern them again after delete-package.
>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
>
> Nobody can fix the economy.  Nobody can be trusted with their finger
> on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Pascal Bourguignon
Subject: Re: asdf unload-op ??
Date: 
Message-ID: <87r70glzun.fsf@thalassa.informatimago.com>
"Karol Skocik" <············@gmail.com> writes:

> all right, and what about if I unintern all symbols in package and then
> delete-package? would this be enough to avoid this problems?

No.  The only effects of deleting a package is to uninternal all the
symbols from this package, and to forget this package name and nicknames.

And this is not a problem, this is a solution!


LISP> (defpackage :exemple (:use :cl) (:export :fun))
#<PACKAGE EXEMPLE>
LISP> (defun exemple:fun (x) (list (second x) (second x)))
EXEMPLE:FUN
LISP> (defun usef (x) (exemple:fun (append x x)))
USEF
LISP> (usef '(1 2 3))
(2 2)
LISP> (function-lambda-expression 'usef)
(LAMBDA (X) (DECLARE (SYSTEM::IN-DEFUN USEF))
 (BLOCK USEF (EXEMPLE:FUN (APPEND X X)))) ;
#(NIL NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION))) ;
USEF
LISP> (unintern 'exemple:fun (find-package :exemple))
T
LISP> (function-lambda-expression 'usef)
(LAMBDA (X) (DECLARE (SYSTEM::IN-DEFUN USEF)) (BLOCK USEF (#:FUN (APPEND X X)))) ;
#(NIL NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION))) ;
USEF
LISP> (usef '(1 2 3))
(2 2)
LISP> (delete-package :exemple)
T
LISP> (usef '(1 2 3))
(2 2)
LISP> 


It's the solution that allows USEF to continue working even after
you've uninterned the symbol EXEMPLE:FUN from the package EXEMPLE, or
after the package EXEMPLE is deleted.

Note how the _same_ symbol is written by PRINT as EXEMPLE:FUN the
first time, and as #:FUN the second time.  It's the same EQ symbol.
The difference,  is that the first time, this symbol was readable and
findable: (find-symbol "FUN" "EXEMPLE") would have returned it, while
the second time, it wasn't readable or findable anymore, (FIND-SYMBOL
"FUN" "EXEMPLE") would return NIL.

In Lisp we don't really "delete" stuff.  We just forget them, and
leave the garbage collector to do its work.  The "delete" functions
don't delete objects, they just modify some data structure.  The
objects are still there alive* or dead*. 



*: garbage collector technical terms.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w--- 
O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++ 
G e+++ h+ r-- z? 
------END GEEK CODE BLOCK------
From: Karol Skocik
Subject: Re: asdf unload-op ??
Date: 
Message-ID: <1153539377.449249.322280@b28g2000cwb.googlegroups.com>
I think I understand now.
Thanks a lot for your reply!

Karol

Pascal Bourguignon wrote:
> "Karol Skocik" <············@gmail.com> writes:
>
> > all right, and what about if I unintern all symbols in package and then
> > delete-package? would this be enough to avoid this problems?
>
> No.  The only effects of deleting a package is to uninternal all the
> symbols from this package, and to forget this package name and nicknames.
>
> And this is not a problem, this is a solution!
>
>
> LISP> (defpackage :exemple (:use :cl) (:export :fun))
> #<PACKAGE EXEMPLE>
> LISP> (defun exemple:fun (x) (list (second x) (second x)))
> EXEMPLE:FUN
> LISP> (defun usef (x) (exemple:fun (append x x)))
> USEF
> LISP> (usef '(1 2 3))
> (2 2)
> LISP> (function-lambda-expression 'usef)
> (LAMBDA (X) (DECLARE (SYSTEM::IN-DEFUN USEF))
>  (BLOCK USEF (EXEMPLE:FUN (APPEND X X)))) ;
> #(NIL NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION))) ;
> USEF
> LISP> (unintern 'exemple:fun (find-package :exemple))
> T
> LISP> (function-lambda-expression 'usef)
> (LAMBDA (X) (DECLARE (SYSTEM::IN-DEFUN USEF)) (BLOCK USEF (#:FUN (APPEND X X)))) ;
> #(NIL NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION))) ;
> USEF
> LISP> (usef '(1 2 3))
> (2 2)
> LISP> (delete-package :exemple)
> T
> LISP> (usef '(1 2 3))
> (2 2)
> LISP>
>
>
> It's the solution that allows USEF to continue working even after
> you've uninterned the symbol EXEMPLE:FUN from the package EXEMPLE, or
> after the package EXEMPLE is deleted.
>
> Note how the _same_ symbol is written by PRINT as EXEMPLE:FUN the
> first time, and as #:FUN the second time.  It's the same EQ symbol.
> The difference,  is that the first time, this symbol was readable and
> findable: (find-symbol "FUN" "EXEMPLE") would have returned it, while
> the second time, it wasn't readable or findable anymore, (FIND-SYMBOL
> "FUN" "EXEMPLE") would return NIL.
>
> In Lisp we don't really "delete" stuff.  We just forget them, and
> leave the garbage collector to do its work.  The "delete" functions
> don't delete objects, they just modify some data structure.  The
> objects are still there alive* or dead*.
>
>
>
> *: garbage collector technical terms.
>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w---
> O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++
> G e+++ h+ r-- z? 
> ------END GEEK CODE BLOCK------
From: Karol Skocik
Subject: Re: asdf unload-op ??
Date: 
Message-ID: <1153539251.526216.114740@p79g2000cwp.googlegroups.com>
I think I understand now.
Thanks a lot for your reply.

Karol

Pascal Bourguignon wrote:
> "Karol Skocik" <············@gmail.com> writes:
>
> > all right, and what about if I unintern all symbols in package and then
> > delete-package? would this be enough to avoid this problems?
>
> No.  The only effects of deleting a package is to uninternal all the
> symbols from this package, and to forget this package name and nicknames.
>
> And this is not a problem, this is a solution!
>
>
> LISP> (defpackage :exemple (:use :cl) (:export :fun))
> #<PACKAGE EXEMPLE>
> LISP> (defun exemple:fun (x) (list (second x) (second x)))
> EXEMPLE:FUN
> LISP> (defun usef (x) (exemple:fun (append x x)))
> USEF
> LISP> (usef '(1 2 3))
> (2 2)
> LISP> (function-lambda-expression 'usef)
> (LAMBDA (X) (DECLARE (SYSTEM::IN-DEFUN USEF))
>  (BLOCK USEF (EXEMPLE:FUN (APPEND X X)))) ;
> #(NIL NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION))) ;
> USEF
> LISP> (unintern 'exemple:fun (find-package :exemple))
> T
> LISP> (function-lambda-expression 'usef)
> (LAMBDA (X) (DECLARE (SYSTEM::IN-DEFUN USEF)) (BLOCK USEF (#:FUN (APPEND X X)))) ;
> #(NIL NIL NIL NIL ((DECLARATION XLIB::CLX-VALUES VALUES OPTIMIZE DECLARATION))) ;
> USEF
> LISP> (usef '(1 2 3))
> (2 2)
> LISP> (delete-package :exemple)
> T
> LISP> (usef '(1 2 3))
> (2 2)
> LISP>
>
>
> It's the solution that allows USEF to continue working even after
> you've uninterned the symbol EXEMPLE:FUN from the package EXEMPLE, or
> after the package EXEMPLE is deleted.
>
> Note how the _same_ symbol is written by PRINT as EXEMPLE:FUN the
> first time, and as #:FUN the second time.  It's the same EQ symbol.
> The difference,  is that the first time, this symbol was readable and
> findable: (find-symbol "FUN" "EXEMPLE") would have returned it, while
> the second time, it wasn't readable or findable anymore, (FIND-SYMBOL
> "FUN" "EXEMPLE") would return NIL.
>
> In Lisp we don't really "delete" stuff.  We just forget them, and
> leave the garbage collector to do its work.  The "delete" functions
> don't delete objects, they just modify some data structure.  The
> objects are still there alive* or dead*.
>
>
>
> *: garbage collector technical terms.
>
> --
> __Pascal Bourguignon__                     http://www.informatimago.com/
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.12
> GCS d? s++:++ a+ C+++ UL++++ P--- L+++ E+++ W++ N+++ o-- K- w---
> O- M++ V PS PE++ Y++ PGP t+ 5+ X++ R !tv b+++ DI++++ D++
> G e+++ h+ r-- z? 
> ------END GEEK CODE BLOCK------