[fpc-pascal] Empty string

Damien Gerard milipili at shikami.org
Fri Mar 7 15:09:36 CET 2008


Le Mar 7, 2008 à 2:54 PM, Jonas Maebe a écrit :

>
> On 03 Mar 2008, at 17:16, Damien Gerard wrote:
>
>> In any programs, a lot of tests on empty strings are made.
>> The following made the work :
>> if Length(s) <> 0 then ...
>> or
>> if s <> '' then ...
>>
>> In a lot of cases, the real length is no needed, just to know if  
>> the string is empty or not.
>
> That is what "if s <> '' then" checks for. This is already generated  
> as optimally as possible.


In a previous thread, I have ask the difference between (Length(s) =  
0) and (s = '')

Copy paste a answer :

>>
>> if s = '' then ...
>> of this one
>> if Length(s) <> 0 then ...
>
> Both generate the same code.


Consequently, it can not be the same code. Otherwise I understood  
nothing :)



--
Damien Gerard
milipili at shikami.org

"Intelligence is 10 million rules."
    -- Douglas Lenat








More information about the fpc-pascal mailing list