[fpc-pascal] Result: string

Flávio Etrusco flavio.etrusco at gmail.com
Mon Mar 4 22:49:41 CET 2013


On Mon, Mar 4, 2013 at 5:23 PM, Juha Manninen <juha.manninen62 at gmail.com> wrote:
> On Mon, Mar 4, 2013 at 9:21 PM, José Mejuto <joshyfun at gmail.com> wrote:
>> What's the expected output of this code ?
>>
>> function TheA(): string;
>> begin
>>   Result:=Result+'A';
>> end;
>>
>> writeln(TheA());
>>
>> I thought that when the result type is an automated one its value gets
>> initialized... Maybe I'm wrong...
>
> Yes you are wrong. It is very illogical because a local string
> variable is initialized to be empty but the return value is not.
> Delphi has the same problem.
>
> I once made even a report about it:
>   http://bugs.freepascal.org/view.php?id=20907
>
>
> Regards,
> Juha

Delphi would present this problem "only" in some situations (which is
worse), and it didn't even show a warning when the result is a string
:-/

-Flávio



More information about the fpc-pascal mailing list