On Tue, 1 Jun 2010 13:05:16 +0200 (CEST)
Michael Van Canneyt <mich...@freepascal.org> wrote:

[...]

Thank you for all answers (all is now clear for me :-).

> > * If a programmer explicitely assigns an existing string to a new variable, 
> > the intent is precisely copy-semantics, to make them independent for 
> > further changes. If there is no change, there is also no reason for such an 
> > assignment.  
> 
> This is not correct. Many strings are simply referenced several times.

May I ask in which typical cases? (I can easily find examples of strings _used_ 
several times, eg concatenated into larger strings and/or output, but this does 
not make new references.)
Can only think at the special case of loop variables:
    for i:=0 to persons.count do begin
        name := persons[i].name;
        -- do something with name w/o changing it --
    end;

I find this question (from a larger point of view than strings only) very 
interesting. Some newer languages, such as Clojure, introduce reference 
semantics while basically preserving basic value immutability: a different 
approach. (I do not mean one is better than the other; instead try to 
understand why either is prefered by some language designers.)


Denis
________________________________

vit esse estrany ☣

spir.wikidot.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to