On 23 Jul 2008, at 06:32, Marc Santhoff wrote:
I understand right that (as I have asked before) an empty (ansi)string is equal to NIL.
True.
If this is correct, is setting a string to '' the same as setting the string to NIL?
No.
So i can e.g. use exchagably: {$H+} var s: string; begin s := 'something'; { this ... } s := ''; { ... works equally to that: } s := NIL;
No, because "s:=nil" doesn't compile. And pointer(s):=nil would create a memory leak.
And more: is the memory consumed by the string freed using one of the two methods?
It is freed if you use s:='' (but keep in mind the earlier discussion about reference counted types: the memory may not be freed immediately, because there may still be hidden references lingering around for a while).
Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal