I have a need to do two things in a #lang:
- Most importantly, make all strings that appear in the source code
immutable
- Second and not as urgent, I'd like to add a "dot" notation, so that
(foo.bar 1 2 3) expands into (foo 'bar 1 2 3)
It seems to me that both of these needs are similar. I can imagine how
to do both by thinking of the syntax tree like a list structure and
rewrite via recursive descent. I guess I would re-append the src
locations to the new structure. This seems doable.
But is it the best way? I'm guessing maybe there's a more racket'y way
but I'm unsure.
On Fri, Nov 8, 2019 at 9:51 AM Christopher Lemmer Webber <cwe...@dustycloud.org> wrote:I have a need to do two things in a #lang:
- Most importantly, make all strings that appear in the source code
immutableMake #%datum turn literal strings `s` into `(string->immutable-string s)`
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.
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.
Huh... somehow I had thought that I had heard that Racket has mutable
strings by default. It cropped up on my TODO list because of that. I
wonder what gave me that impression?