Re: copy one character from a string.
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 Nov 2005 15:03:43 +0100
<alanglloyd@xxxxxxx> wrote in message
news:1132838168.132401.64210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
<using SetLength instead of UniqueString, for the express purpose
of ensuring a string has a reference count of one>
> I'm only following advice in Delphi Help <g> ...
>
> "procedure UniqueString(var S: string);
>
> Description
> Following a call to SetString, S is guaranteed to reference a unique
> string; that is, a string with a reference count of one. For normal
> string handling, there is no need to ever call UniqueString. Only in
> cases where an application casts a string to a PChar and then modifies
> the contents of the string must UniqueString be used."
>
> ...or is there something else subtle which UniqueString or SetLength
> does ?
No, messing with the refcount is subtle enough as it is. I've learned to
take statements of the form "arcane; internal use only; keep out" with a
small grain of salt. Only about five kilos. The moment you realise the
reference count matters to you, you've already left the realm of "normal
string handling".
I consider it counterproductive to warn people away from functions that
"there is no need to ever call", if it pushes them towards using more
mainstream functions instead that do not as concisely express their intent.
Groetjes,
Maarten Wiltink
.
- Follow-Ups:
- Re: copy one character from a string.
- From: J French
- Re: copy one character from a string.
- References:
- copy one character from a string.
- From: MLian
- Re: copy one character from a string.
- From: Dodgy
- Re: copy one character from a string.
- From: MLian
- Re: copy one character from a string.
- From: Bjørge
- Re: copy one character from a string.
- From: alanglloyd@xxxxxxx
- Re: copy one character from a string.
- From: Maarten Wiltink
- Re: copy one character from a string.
- From: alanglloyd@xxxxxxx
- copy one character from a string.
- Prev by Date: Re: copy one character from a string.
- Next by Date: Re: copy one character from a string.
- Previous by thread: Re: copy one character from a string.
- Next by thread: Re: copy one character from a string.
- Index(es):
Relevant Pages
|