Hi,
It seems to me that it is possible to create
(scala.collection.immutable.)List instances via multithreaded access
to a ListBuffer which can be viewed in multiple states (instead of a
single one).
Is this not perceived as a problem? Understandably, one should never
put a ListBuffer in concurrent usage, but buggy code could. I can only
imagine how mysterious such a bug would appear if it only manifested
itself as a List that appears to be mutable - pretty much nobody would
believe he saw the list really mutating, most would assume that these
were somehow different List instances and be misguided about the root
of the problem.
If this was to be plugged while not sacrificing the O(1) behavior of
ListBuffer.toList, I don't see many options apart from synchronizing
all ListBuffer mutators (the cost of which would almost be eliminated
at runtime for thread-local ListBuffers), which then would resemble
java.lang.StringBuffer (particularly, its old design that also had a
O(1) toString method, not the current copying behavior).
Comments?
Regards,
Dimitris