[fpc-pascal]ansistring question

Jonas Maebe jonas at zeus.rug.ac.be
Fri Jan 3 17:01:42 CET 2003

On vrijdag, jan 3, 2003, at 16:28 Europe/Brussels, Mark Emerson wrote:

> Consider the equation in the if statement:
> var
>   a, b : ansistring;
> begin
>   a := 'hello world..and a lot of other stuff to make this string 
> long';
>   b := a;
>   if a=b then write ('idential');
> end.
> How is a=b evaluated?  I hope/presume the text in the string is not
> taken into consideration at all, and that the system can immediately 
> see
> that they are identical.  Am I right?

No. How would the system know that? You can have two completely 
unrelated ansistrings with the same content (just do a readln() of two 
ansistrings and type in twice the same text), so a full string compare 
is necessary. It would be possible to make the comparison a two step 
process, in which we first check whether the ansistrings point to the 
same ansistring structure and only if that fails, start doing an actual 
string compare, but I doubt this will gain you much a most real world 


More information about the fpc-pascal mailing list