[racket-dev] literal strings and numbers are now interned

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Nov 22 21:01:48 EST 2011

'case' seems a lot more useful now than it used to be.


On Tue, Nov 22, 2011 at 10:18 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> As of v5.2.0.4, Racket's reader and `datum->syntax' interns literal
> strings, byte strings, regexps, characters, and numbers. (Also,
> `equal?' now works in the obvious way for regexps.)
> For example, `(eq? "hello" "hello")' will always return true, since the
> two literal "hello"s are interned to the same string. Of course, it's
> best not to write code that depends on this subtle fact, but the
> reader's interning behavior is specified.
> The change is intended to simplify cross-module optimization. The
> compiler can now inline an inexact number bound to `pi', for example,
> without potentially changing the semantics of a program that uses
> something like `(eq? pi pi)'. Probably no good program would break with
> cross-module inlining of numbers even without interning, but it seems
> simplest to dispense with the question by always interning.
> Along the same lines, I think it's unlikely that good programs are
> affected by the `read' interning change, although I had to fix some
> Racket tests that specifically check `eq?'-related behavior. Since
> `datum->syntax' also interns literals, it's possible that the change
> defeats some use of 3-D syntax that depends on the identity of a string
> or number; again, though, that seems unlikely.
> Finally, it's unlikely that interning alone will provide any
> performance improvement. Fewer copies of strings and numbers may be
> retained, but those savings probably just pay for the overhead of the
> intern table.
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/dev

Posted on the dev mailing list.