[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Are symbols garbage collected?
From: |
Christopher Allan Webber |
Subject: |
Re: Are symbols garbage collected? |
Date: |
Mon, 23 Oct 2017 14:30:53 -0500 |
User-agent: |
mu4e 0.9.18; emacs 25.3.1 |
David Kastrup writes:
> 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.
Thanks for the reply! That's helpful. Dave Thompson also did a little
demo for me, and I'm totally convinced that symbols are GC'ed now. :)