From: AngelP on
Hi,

When asdf system is loaded, I create and image, but I do not want asdf
to be in the image itself.
Is there a way to unload asdf when a system is composed?

Regards, AngelP
From: Captain Obvious on
A> When asdf system is loaded, I create and image, but I do not want asdf
A> to be in the image itself.

Why?

A> Is there a way to unload asdf when a system is composed?

delete-package will do that. In Common Lisp you can't really delete stuff,
only make it non-accessible so it can be garbage collected, so results
might depend on implementation you use and other factors.


From: Jochen Schmidt on
On 2010-01-06 05:08:20 +0100, AngelP said:

> Hi,
>
> When asdf system is loaded, I create and image, but I do not want asdf
> to be in the image itself.
> Is there a way to unload asdf when a system is composed?

You cannot "unload" it. The only thing you can try is getting it
garbage collected. Before you go down that route you should ask
yourself why this is actually necessary - ASDF isn't really a big
library.

ciao,
Jochen

--
Jochen Schmidt
CRISPYLOGICS
Uhlandstr. 9, 90408 Nuremberg

Fon +49 (0)911 517 999 82
Fax +49 (0)911 517 999 83

mailto:(format nil "~(~36r@~36r.~36r~)" 870180 1680085828711918828
16438) http://www.crispylogics.com

From: AngelP on
On 6 Ян, 13:50, Jochen Schmidt <j...(a)codeartist.org> wrote:
> On 2010-01-06 05:08:20 +0100, AngelP said:
>
> > Hi,
>
> > When asdf system is loaded, I create and image, but I do not want asdf
> > to be in the image itself.
> > Is there a way to unload asdf when a system is composed?
>
> You cannot "unload" it. The only thing you can try is getting it
> garbage collected. Before you go down that route you should ask
> yourself why this is actually necessary - ASDF isn't really a big
> library.
>
> ciao,
> Jochen
>
> --
> Jochen Schmidt
> CRISPYLOGICS
> Uhlandstr. 9, 90408 Nuremberg
>
> Fon +49 (0)911 517 999 82
> Fax +49 (0)911 517 999 83
>
> mailto:(format nil "~(~36r@~36r.~36r~)" 870180 1680085828711918828
> 16438)http://www.crispylogics.com

Thanks,

The image is small and added overhead to the image is noticeable,
but I could live with it, if there is no other way.

Regards, AngelP
From: Pascal J. Bourguignon on
AngelP <angelpopov(a)gmail.com> writes:
> When asdf system is loaded, I create and image, but I do not want asdf
> to be in the image itself.
> Is there a way to unload asdf when a system is composed?

I would use something like:


(defun topological-sort (nodes lessp)
"
RETURN: A list of NODES sorted topologically according to
the partial order function LESSP.
If there are cycles (discounting reflexivity),
then the list returned won't contain all the NODES.
"
(loop
:with sorted = '()
:with incoming = (map 'vector (lambda (to)
(loop
:for from :in nodes
:when (and (not (eq from to))
(funcall lessp from to))
:sum 1))
nodes)
:with q = (loop
:for node :in nodes
:for inco :across incoming
:when (zerop inco)
:collect node)
:while q
:do (let ((n (pop q)))
(push n sorted)
(loop
:for m :in nodes
:for i :from 0
:do (when (and (and (not (eq n m))
(funcall lessp n m))
(zerop (decf (aref incoming i))))
(push m q))))
:finally (return (nreverse sorted))))


(defun package-use*-package-p (p q)
"
RETURN: Whether the package P uses the package Q, or a package
that uses the package Q.
NOTE: By definition, (PACKAGE-USE*-PACKAGE-P X X)
"
(setf p (find-package p)
q (find-package q))
(loop
:with processed = '()
:with used = (list p)
:while used
;; :do (print (list used processed))
:do (let ((current (pop used)))
(if (eq current q)
(return-from package-use*-package-p t)
(progn
(push current processed)
(dolist (new (package-use-list current))
(unless (member new processed)
(pushnew new used))))))
:finally (return-from package-use*-package-p nil)))


(defun remove-asdf ()
(map nil (function delete-package)
(topological-sort
(remove-if (lambda (n)
(or (string= n "ASDF")
(and (< 5 (length n))
(string= "ASDF-" n :end2 5))))
(copy-list (list-all-packages))
:key (function package-name))
(function package-use*-package-p))))

(remove-asdf)
#+clisp (ext:gc)



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