Re: Garbage collector - ccl:terminate (memory stuff)

Tim Bradshaw <[email protected]> Wed, 1 May 2024 11:27:09 +0100
Newsgroups gmane.lisp.openmcl.devel
Message-ID <[email protected]>
--Apple-Mail-9E031DFA-2B9E-4BE4-BE6A-95410EE6A81F
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

Another approach to this is to simply reuse symbols that already are interne=
d elsewhere, particularly CL:

(do-symbols (symbol "FRICAS-LISP")
  (export (list symbol) "FRICAS-LISP"))

This is legal, and readable.

Obscure note: you need (export (list s) ...) because otherwise at some point=
 you end up saying (export nil ...).

--tim

> On 27 Apr 2024, at 13:37, Rainer Joswig <[email protected]> wrote:
>=20
> =EF=BB=BF
>=20
>> Am 27.04.2024 um 13:41 schrieb Gr=C3=A9gory Vanuxem <[email protected]>=
:
>>=20
>>=20
>> As a last note, there is a strange "routine" in the FRICAS-LISP
>> package (BOOT, the interpreter and algebra libraries use it) that I do
>> not really understand, wouldn't it be related? I can eventually "play"
>> with this piece of code (some code parts are cutted below):
>>=20
>> (make-package "FRICAS-LISP"
>>     :use (list (or (find-package "COMMON-LISP")
>>                    "LISP")))
>>=20
>> Here is the piece of code I do not totally understand and if it has
>> effect on CCL symbols that prevents me to define the ccl:terminate or
>> ccl::terminate method on jlref object:
>>=20
>> ;;; We use uninterned symbols because at this point we do not
>> ;;; want to add symbols to FRICAS-LISP
>> (let ((#1=3D#:ls nil))
>>    (do-symbols (#2=3D#:el "FRICAS-LISP") (setf #1# (cons #2# #1#)))
>>    (mapcar (lambda (#3=3D#:x) (export (list #3#))) #1#)
>> )
>=20
>=20
>=20
> The form above could be replaced by:
>=20
> (mapcar #'export (apropos-list "" "FRICAS-LISP"))
>=20
> It simply exports all symbols in the package "FRICAS-LISP" from the curren=
t package at that point, avoiding interning new symbols by the code itself.
>=20
>=20
> If one want to control from where to export, then we can use this:
>=20
> (mapcar #'(lambda (#1=3D#:fricas-lisp-symbol) (export #1# "FRICAS-LISP"))
>               (apropos-list "" "FRICAS-LISP"))
>=20
>=20

--Apple-Mail-9E031DFA-2B9E-4BE4-BE6A-95410EE6A81F
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto"><div dir=3D"ltr"></div><div dir=3D"ltr">Ano=
ther approach to this is to simply reuse symbols that already are interned e=
lsewhere, particularly CL:</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">=
(do-symbols (symbol "FRICAS-LISP")</div><div dir=3D"ltr">&nbsp; (export (lis=
t symbol) "FRICAS-LISP"))</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">T=
his is legal, and readable.</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"=
>Obscure note: you need (export (list s) ...) because otherwise at some poin=
t you end up saying (export nil ...).</div><div dir=3D"ltr"><br></div><div d=
ir=3D"ltr">--tim</div><div dir=3D"ltr"><br><blockquote type=3D"cite">On 27 A=
pr 2024, at 13:37, Rainer Joswig &lt;[email protected]&gt; wrote:<br><br></bloc=
kquote></div><blockquote type=3D"cite"><div dir=3D"ltr">=EF=BB=BF<meta http-=
equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8"><br id=3D"line=
BreakAtBeginningOfMessage"><div><br><blockquote type=3D"cite"><div>Am 27.04.=
2024 um 13:41 schrieb Gr=C3=A9gory Vanuxem &lt;[email protected]&gt;:</div=
><br class=3D"Apple-interchange-newline"><div><meta charset=3D"UTF-8"><br st=
yle=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; f=
ont-style: normal; font-variant-caps: normal; font-weight: 400; letter-spaci=
ng: normal; text-align: start; text-indent: 0px; text-transform: none; white=
-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-deco=
ration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-family: Helvet=
ica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-we=
ight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text=
-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-strok=
e-width: 0px; text-decoration: none; float: none; display: inline !important=
;">As a last note, there is a strange "routine" in the FRICAS-LISP</span><br=
 style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px=
; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-sp=
acing: normal; text-align: start; text-indent: 0px; text-transform: none; wh=
ite-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-d=
ecoration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-family: Hel=
vetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font=
-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; t=
ext-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-st=
roke-width: 0px; text-decoration: none; float: none; display: inline !import=
ant;">package (BOOT, the interpreter and algebra libraries use it) that I do=
</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-=
size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400;=
 letter-spacing: normal; text-align: start; text-indent: 0px; text-transform=
: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0=
px; text-decoration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-f=
amily: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: no=
rmal; font-weight: 400; letter-spacing: normal; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webk=
it-text-stroke-width: 0px; text-decoration: none; float: none; display: inli=
ne !important;">not really understand, wouldn't it be related? I can eventua=
lly "play"</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvet=
ica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-we=
ight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text=
-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-strok=
e-width: 0px; text-decoration: none;"><span style=3D"caret-color: rgb(0, 0, 0=
); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant=
-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; t=
ext-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0p=
x; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; displ=
ay: inline !important;">with this piece of code (some code parts are cutted b=
elow):</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica;=
 font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight=
: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-tra=
nsform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-wi=
dth: 0px; text-decoration: none;"><br style=3D"caret-color: rgb(0, 0, 0); fo=
nt-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps=
: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-=
indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -=
webkit-text-stroke-width: 0px; text-decoration: none;"><span style=3D"caret-=
color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: no=
rmal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; t=
ext-align: start; text-indent: 0px; text-transform: none; white-space: norma=
l; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;=
 float: none; display: inline !important;">(make-package "FRICAS-LISP"</span=
><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 1=
4px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter=
-spacing: normal; text-align: start; text-indent: 0px; text-transform: none;=
 white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; tex=
t-decoration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-family: H=
elvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; fo=
nt-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px;=
 text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-=
stroke-width: 0px; text-decoration: none; float: none; display: inline !impo=
rtant;">&nbsp;&nbsp;&nbsp;&nbsp;:use (list (or (find-package "COMMON-LISP")<=
/span><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-s=
ize: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; l=
etter-spacing: normal; text-align: start; text-indent: 0px; text-transform: n=
one; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;=
 text-decoration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-fami=
ly: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: norma=
l; font-weight: 400; letter-spacing: normal; text-align: start; text-indent:=
 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-=
text-stroke-width: 0px; text-decoration: none; float: none; display: inline !=
important;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"LISP")))</span><br style=3D=
"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-st=
yle: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: no=
rmal; text-align: start; text-indent: 0px; text-transform: none; white-space=
: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration=
: none;"><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; fon=
t-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 40=
0; letter-spacing: normal; text-align: start; text-indent: 0px; text-transfo=
rm: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width:=
 0px; text-decoration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font=
-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: n=
ormal; font-weight: 400; letter-spacing: normal; text-align: start; text-ind=
ent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -web=
kit-text-stroke-width: 0px; text-decoration: none; float: none; display: inl=
ine !important;">Here is the piece of code I do not totally understand and i=
f it has</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetic=
a; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weig=
ht: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-t=
ransform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-=
width: 0px; text-decoration: none;"><span style=3D"caret-color: rgb(0, 0, 0)=
; font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-=
caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; t=
ext-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0p=
x; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; displ=
ay: inline !important;">effect on CCL symbols that prevents me to define the=
 ccl:terminate or</span><br style=3D"caret-color: rgb(0, 0, 0); font-family:=
 Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; f=
ont-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px=
; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text=
-stroke-width: 0px; text-decoration: none;"><span style=3D"caret-color: rgb(=
0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-=
variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: s=
tart; text-indent: 0px; text-transform: none; white-space: normal; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none=
; display: inline !important;">ccl::terminate method on jlref object:</span>=
<br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 1=
4px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter=
-spacing: normal; text-align: start; text-indent: 0px; text-transform: none;=
 white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; tex=
t-decoration: none;"><br style=3D"caret-color: rgb(0, 0, 0); font-family: He=
lvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; fon=
t-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; t=
ext-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-st=
roke-width: 0px; text-decoration: none;"><span style=3D"caret-color: rgb(0, 0=
, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-vari=
ant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: star=
t; text-indent: 0px; text-transform: none; white-space: normal; word-spacing=
: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; d=
isplay: inline !important;">;;; We use uninterned symbols because at this po=
int we do not</span><br style=3D"caret-color: rgb(0, 0, 0); font-family: Hel=
vetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font=
-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; t=
ext-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-st=
roke-width: 0px; text-decoration: none;"><span style=3D"caret-color: rgb(0, 0=
, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-vari=
ant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: star=
t; text-indent: 0px; text-transform: none; white-space: normal; word-spacing=
: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; d=
isplay: inline !important;">;;; want to add symbols to FRICAS-LISP</span><br=
 style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px=
; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-sp=
acing: normal; text-align: start; text-indent: 0px; text-transform: none; wh=
ite-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-d=
ecoration: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-family: Hel=
vetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font=
-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; t=
ext-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-st=
roke-width: 0px; text-decoration: none; float: none; display: inline !import=
ant;">(let ((#1=3D#:ls nil))</span><br style=3D"caret-color: rgb(0, 0, 0); f=
ont-family: Helvetica; font-size: 14px; font-style: normal; font-variant-cap=
s: normal; font-weight: 400; letter-spacing: normal; text-align: start; text=
-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -=
webkit-text-stroke-width: 0px; text-decoration: none;"><span style=3D"caret-=
color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: no=
rmal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; t=
ext-align: start; text-indent: 0px; text-transform: none; white-space: norma=
l; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;=
 float: none; display: inline !important;">&nbsp;&nbsp;&nbsp;(do-symbols (#2=
=3D#:el "FRICAS-LISP") (setf #1# (cons #2# #1#)))</span><br style=3D"caret-c=
olor: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: nor=
mal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; te=
xt-align: start; text-indent: 0px; text-transform: none; white-space: normal=
; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"=
><span style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size=
: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; let=
ter-spacing: normal; text-align: start; text-indent: 0px; text-transform: no=
ne; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; t=
ext-decoration: none; float: none; display: inline !important;">&nbsp;&nbsp;=
&nbsp;(mapcar (lambda (#3=3D#:x) (export (list #3#))) #1#)</span><br style=3D=
"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-st=
yle: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: no=
rmal; text-align: start; text-indent: 0px; text-transform: none; white-space=
: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration=
: none;"><span style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; f=
ont-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: 4=
00; letter-spacing: normal; text-align: start; text-indent: 0px; text-transf=
orm: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width=
: 0px; text-decoration: none; float: none; display: inline !important;">)</s=
pan><br style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-siz=
e: 14px; font-style: normal; font-variant-caps: normal; font-weight: 400; le=
tter-spacing: normal; text-align: start; text-indent: 0px; text-transform: n=
one; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;=
 text-decoration: none;"></div></blockquote></div><div><br></div><br><div>Th=
e form above could be replaced by:</div><div><br></div><div>(mapcar #'export=
 (apropos-list "" "FRICAS-LISP"))</div><div><br></div><div>It simply exports=
 all symbols in the package "FRICAS-LISP" from the current package at that p=
oint, avoiding interning new symbols by the code itself.</div><div><br></div=
><div><br></div><div>If one want to control from where to export, then we ca=
n use this:</div><div><br></div><div>(mapcar #'(lambda (#1=3D#:fricas-lisp-s=
ymbol) (export #1# "FRICAS-LISP"))</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; (apropos-list "" "FRICAS-LISP"))</div><div><br></div><div>=
<br></div></div></blockquote></body></html>=

--Apple-Mail-9E031DFA-2B9E-4BE4-BE6A-95410EE6A81F--