guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are symbols garbage collected?


From: David Kastrup
Subject: Re: Are symbols garbage collected?
Date: Mon, 23 Oct 2017 21:03:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Christopher Allan Webber <address@hidden> writes:

> I thought they weren't but now I'm not really sure where I got that
> idea from.  Does anyone know for sure?

They are garbage-collected.  This is not overly relevant outside of
C/C++ code since as long as any code references a symbol, it will stay
around.  It's only when you look at things like its address independent
of the symbol that you'd notice.

scheme@(guile-user)> (object-address 'blablaaaaaa)
$4 = 94515697299616
scheme@(guile-user)> (gc)
scheme@(guile-user)> (object-address 'blablaaaaaa)
$5 = 94515696660320
scheme@(guile-user)> 

Similar for hashq: without the symbol being stored somewhere, it will
likely deliver different values each time round.

If you put this into code rather than retyping it on the command line,
the address will be the same each time.  You'd need to use something
like
(string->symbol "blablaaaaaa")
in order to get different addresses: a literal symbol in the code would
be protected.

-- 
David Kastrup




reply via email to

[Prev in Thread] Current Thread [Next in Thread]