On 13.02.13 02:09, Alexandre Vassalotti wrote:
On Tue, Feb 12, 2013 at 1:44 PM, Antoine Pitrou <email@example.com mailto:firstname.lastname@example.org> wrote:
It's idiomatic because strings are immutable (by design, not because of an optimization detail) and therefore concatenation *has* to imply building a new string from scratch.
Not necessarily. It is totally possible to implement strings such they are immutable and concatenation takes O(1): ropes are the canonical example of this.
Ropes have been implemented by Carl-Friedrich Bolz in 2007 as I remember. No idea what the impact was, if any at all. Would ropes be an answer (and a simple way to cope with string mutation patterns) as an alternative implementation, and therefore still justify the usage of that pattern?