<br><br><div class="gmail_quote">2011/12/19 Sascha Ziemann <span dir="ltr"><<a href="mailto:ceving@gmail.com">ceving@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

2011/12/14 Marc Feeley <<a href="mailto:feeley@iro.umontreal.ca">feeley@iro.umontreal.ca</a>>:<br>
<div class="im">><br>
> When a Scheme string is "converted" to a C string by the C-interface, it is a newly allocated object on the C heap.  In other words, the object that C is receiving is unrelated to the Scheme object managed by the Gambit garbage-collector.  The C string will *not* be moved around, but it does have a reference count which allows more control over the reclaiming of that string from the C side.<br>


<br>
</div>So there are two strings: one on the Scheme side and one on the C<br>
side. The one on the Scheme side probably does not have any Scheme<br>
references any more but has one reference coming from the C side.<br>
<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Isn't this a bit much overhead to keep the string on the Scheme side,<br>
only to have a reference to the copy of the string on the C side?<br></blockquote><div><br>You can access the Scheme string's content "raw" as well from C. The point with the conveniency wrapper into char* etc. in C, is to give you a latin1/utf8/etc. encoded character sequence rather than the internal 32bit/etc. unicode form.<br>

 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
And another question: if there are also references on the Scheme side<br>
to the string which get used to modify the string: will the C side<br>
know about the modification?<br></blockquote><div><br>No afaik<br> <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Example:<br>
<br>
(let ((ident "A"))<br>
  (openlog ident ...)<br>
  (syslog "a")<br>
  (set! ident "B")<br>
  (syslog "b"))<br>
<br>
Will the output be<br>
<br>
A: a<br>
B: b<br>
<br>
or<br>
<br>
A: a<br>
A: b<br>
<div class="HOEnZb"><div class="h5"><br>
?<br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</div></div></blockquote></div><br>