<div dir="ltr">thanks Bill, I would not have found that solution on my own. GC question time! In this case I am recursively walking a Max dictionary structure to convert to a hash or vice versa. If I gc_protect the hash, am I good for any dynamically created entries too during this traversal process? Or should I be turning off the gc entirely until the traversal is done? Am I correct in understanding that the issue is that the GC might collect items that were made from C but not in scheme?<div><br></div><div>thanks again, getting close to a major upgrade in usefulness here!</div><div>iain</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 8, 2020 at 2:45 AM <<a href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I would use s7_iterate which underlies map and for-each:<br>
<br>
s7_pointer iter, hash, x;<br>
s7_int gc1, gc2;<br>
<br>
hash = s7_make_hash_table(sc, 8);<br>
gc1 = s7_gc_protect(sc, hash);<br>
s7_hash_table_set(sc, hash, s7_make_symbol(sc, "a"), <br>
s7_make_integer(sc, 1));<br>
s7_hash_table_set(sc, hash, s7_make_symbol(sc, "b"), <br>
s7_make_integer(sc, 2));<br>
<br>
iter = s7_make_iterator(sc, hash);<br>
gc2 = s7_gc_protect(sc, iter);<br>
<br>
x = s7_iterate(sc, iter); /* (a . 1) */<br>
fprintf(stderr, "x: %s\n", s7_object_to_c_string(sc, x));<br>
x = s7_iterate(sc, iter); /* (b . 2) */<br>
fprintf(stderr, "x: %s\n", s7_object_to_c_string(sc, x));<br>
x = s7_iterate(sc, iter); /* #<eof> == end */<br>
fprintf(stderr, "x: %s\n", s7_object_to_c_string(sc, x));<br>
<br>
s7_gc_unprotect_at(sc, gc1);<br>
s7_gc_unprotect_at(sc, gc2);<br>
<br>
</blockquote></div>