[gambit-list] Low prio feature request: GC:able symbols, perhaps via a separate configure option --enable-gc:able-symbols

David Rush kumoyuki at gmail.com
Wed Sep 25 03:46:20 EDT 2013


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 at 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 at 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 at 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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130925/c61b5bb4/attachment.htm>


More information about the Gambit-list mailing list