unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: guile-user@gnu.org
Subject: Re: Are symbols garbage collected?
Date: Mon, 23 Oct 2017 21:03:41 +0200	[thread overview]
Message-ID: <87d15delf6.fsf@fencepost.gnu.org> (raw)
In-Reply-To: 87fua9n48o.fsf@dustycloud.org

Christopher Allan Webber <cwebber@dustycloud.org> 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




  parent reply	other threads:[~2017-10-23 19:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-23 17:49 Are symbols garbage collected? Christopher Allan Webber
2017-10-23 18:16 ` Marko Rauhamaa
2017-10-23 19:35   ` Christopher Allan Webber
2017-10-23 19:03 ` David Kastrup [this message]
2017-10-23 19:30   ` Christopher Allan Webber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d15delf6.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).