this is silly. The case that the OP is worried about should really be using a hash table. Symbols are simply the wrong thing.


On 24 September 2013 23:39, Mikael <mikael.rcv@gmail.com> wrote:
More complete example:

> (define t (make-table weak-keys: #t weak-values: #t))
> (table-set! t (string->symbol "abc") (string->symbol "def"))
> (table-set! t "ghi" "jkl")
> (table-set! t (make-uninterned-symbol "mno") (make-uninterned-symbol "pqr"))
> (table-set! t 'st 'uv)
> (table-set! t (read (open-input-string "w")) (read (open-input-string "x")))
> (##gc) (##gc) (##gc)
> > > (table->list t)
((st . uv) (w . x) (abc . def))


(Note that if you compile this code and load it, the "ghi" and "jkl" strings will not GC too as they're now part of the compiled code, which does not GC. Eval:ed code GC:s.)



2013/9/25 Mikael <mikael.rcv@gmail.com>
Ordinary symbols are special in that they are the only values created by Scheme code on runtime that are not garbage collected currently.

(The other ones would be any compiled code you load and ___PERM objects you allocate in C.)

Compare:

> (define t (make-table weak-keys: #t weak-values: #t))
> (table-set! t (string->symbol "abc") (string->symbol "def"))
> (table-set! t "ghi" "jkl")
> (table-set! t (make-uninterned-symbol "mno") (make-uninterned-symbol "pqr"))
> (##gc) (##gc) (##gc)
> > > (table->list t)
((abc . def))


2013/9/25 Adrien Piérard <pierarda@iro.umontreal.ca>
Hum, I might have completely misunderstood many things, from what you
wrote to how symbols work, but what if I have a symbol stored as a
weak reference in a table, and it gets garbage collected. If I later
re-read this symbol from the network, then I won't find it in the
table, will I? But wasn't I guaranteed I'd find it  *because* it's a
symbol and thus the table should still be containing an element EQ to
the one I just got from the network?

P!



_______________________________________________
Gambit-list mailing list
Gambit-list@iro.umontreal.ca
https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list




--
GPG Public key at http://cyber-rush.org/drr/gpg-public-key.txt