Javari's Reference Immutability
Hasan Aljudy
hasan.aljudy at gmail.com
Thu Jul 27 19:27:06 PDT 2006
Regan Heath wrote:
> On Thu, 27 Jul 2006 18:39:29 -0600, Hasan Aljudy
> <hasan.aljudy at gmail.com> wrote:
>
>> You say that Java's String class implies alot of copying, therefor
>> it's bad. However, you fail to realize that copying when modifying is
>> exactly what COW stands for. COW is a kind of honor-system protocol
>> implemented by phobos. Everytime phobos thinks it needs to modify a
>> string which it doesn't own, it makes a copy first to keep the
>> original string intact. In Java, this can be done by creating a
>> StringBuffer from the String (which creates a copy), after that, any
>> modification you make to StringBuffer happens in-place; no needless
>> copying.
>
>
> Sure. But are you trying to tell me that this..
>
> String foo(String a) { .. return modified a .. }
> String bar(String a) { .. return modified a .. }
> String baz(String a) { .. return modified a .. }
> String bob(String a) { .. return modified a .. }
>
> String s = foo(bar(baz(bob("test"))));
>
> Will result in _no_ needless copying?
>
> Regan
Same thing will happen will happen with phobos COW
P.S. Are you (or Reiner Pope) saying that Javari provides a better
solution to this? <g>
More information about the Digitalmars-d-learn
mailing list