Hacker News new | ask | show | jobs
by TazeTSchnitzel 1534 days ago
You can intern strings without preventing mutability using the copy-on-write principle. PHP does it.
1 comments

If you copy before you write, you're not mutating, you're making a new thing.

e.g. This pseudo code must stand for mutation to be present.

    a = ...
    b = a
    mutate(a)
    /* b now mirrors a */
A language runtime can make that work if it wants to. High-level semantics don't need to constrain the implementation.