On Wed, 16 May 2001, Yukihiro Matsumoto wrote:
> The only elegant solution I can think of:
> 
>   * introduce reference counting.
> 
>   * + for String and Array (and others) concat to self, if reference
>     count is 1, which means there's no alias to the object.

What do you think of adding an extra level of indirection? Maybe String
objects could point to a datastructure like: 

struct InnerString {

	int refcount; /* how many RSTRINGs point to this struct */

	int length;
	int capacity;
	char data[0];
};


So that you don't need to add reference counting anywhere else than in
String.


matju