Am 07.07.2011 08:35, schrieb Alexander Klenin:
>> As further support for #1, consider: With a class, you do not have to pass
>> it to a procedure as var, but when you modify the instance, you modify the
>> same instance as was passed to the procedure. That is how classes work.
>> Having a variable point to the same object as another variable does in fact
>> mean it's the same instance, the same object. That is Object Pascal's object
>> model. But with strings, if you want to modify the string in a procedure and
>> have that affect the argument initially passed to the procedure you *have*
>> to use var. That alone should be convincing evidence that the programmer is
>> always supposed to be able to assume that unique variables are unique
>> instances for automatically managed strings and arrays.
> This is also a good argument which I omitted before in the interests of 
> brevity.
> 
> Put in another words, current "const string" implementation honors the
> implicit contract of
> "adding const in front of the string parameter cancels refcounting",
> at the cost of breaking the implicit contract of "refcounted values
> are indistinguishable
> from simple values (except maybe in performance)".

As I have shown before in this thread, non ref. counted values e.g.
shortstrings are affected by the same problem.
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to