On Wed 04 Jan 2012 13:31, Mark H Weaver <m...@netris.org> writes:

> Andy Wingo <wi...@pobox.com> writes:
>> We could add a compiler option to turn string literals into (string-copy
>> FOO).  Perhaps that's the thing to do.
>
> I think this would be fine, as long as the default is _not_ to copy
> string literals.  This would help Bruce a great deal with very little
> effort on our part, without mucking up the semantics for anyone else.

Yes, this was what I was thinking.

> David Kastrup <d...@gnu.org> writes:
>> What for?  It would mean that a literal would not be eq? to itself, a
>> nightmare for memoization purposes.
>
> I agree that it should not be the default behavior, but I don't see the
> harm in allowing users to compile their own code this way.

Well, we can fix this too: we can make

  "foo"

transform to

  (copy-once UNIQUE-GENSYM str)

with

(define (copy-once key str)
  (or (hashq-ref mutable-string-literals key)
      (let ((value (string-copy str)))
        (hashq-set! mutable-string-literals key value)
        value)))

Andy
-- 
http://wingolog.org/

Reply via email to