On Fri, Nov 8, 2019 at 2:58 PM Matthew Flatt <mfl...@cs.utah.edu> wrote:

> More precisely, the reader (via `read-syntax`) creates immutable
> strings.
>
> If a macro constructs a mutable string and converts it to a syntax
> object, the string is not converted to an immutable string. Maybe it
> should be.
>

I see now that this is true, but it isn't what I'd expected. The docs
<https://docs.racket-lang.org/reference/stxops.html#(def._((quote._~23~25kernel)._datum-~3esyntax))>
for `datum->syntax` say that:

> For any kind of value other than a pair, vector, box, immutable hash
> table, immutable prefab structure, or syntax object, conversion means
> wrapping the value with lexical information, source-location information,
> and properties after the value is interned via datum-intern-literal.
>
and `datum-intern-literal` says
<https://docs.racket-lang.org/reference/stxops.html#%28def._%28%28quote._~23~25kernel%29._datum-intern-literal%29%29>
that "mutable strings and byte strings are interned as immutable strings
and byte strings," which I just confirmed is true.

Based on this, I'd previously thought that using `datum->syntax` on a
mutable string would convert the string with `datum-intern-literal`, which
would make the wrapped string immutable—but I see now that the wrapped
string is, in fact, still mutable.

-Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAH3z3gb%2Bztz62%2BykWpZNbNQ1gPy70LVWB_%3DMpkLxKApScJiPEQ%40mail.gmail.com.

Reply via email to