[Lazarus] Some syntax changes
Hans-Peter Diettrich
DrDiettrich1 at aol.com
Sat Jul 31 16:20:09 CEST 2010
Mattias Gaertner schrieb:
>> A simple example:
>>
interface
>> function GetProp: byte;
>> var
>> test: integer;
>> property
>> prop1: byte read GetProp;
>> prop2: byte read GetProp;
implementation
function GetProp: byte;
begin
Result := 0; //whatever you like. check code completion for "Result"
end;
>
> Local properties? I didn't know that this is allowed.
Above snippet should be in the *interface* part of a unit, see above.
Sorry for the confusion :-(
> And my four
> days old fpc 2.5.1 gives a strange error:
>
> Error: Resourcestrings can be only static or global
That's definitely a bug. If one of the FPC developers lurks:
procedure psub.property_dec, line 673: parser_e_resourcstring_only_sg is
wrong message. A new message parser_e_property_... is required.
>>>> The usage of an function name instead of the Result variable has been
>>>> restricted. For some reason Lazarus now rejects "Result" in code
>>>> completion, even if it is accepted by the compiler.
>>> Can you give an example or better: the definition?
>> This happened to me in a property getter function, i.e. in the GetProp
>> implementation in above example. So it may be related to the above
>> property problem.
>
> I don't know. The above does not compile.
Please try again.
>>>> It also seems that Lazarus has problems with $IF, even simple
>>>> expressions are not evaluated properly, so that the wrong branch is
>>>> handled as enabled/disabled.
>>> Can you give an example?
>> Commandline option: -dMyConst:=1 (may work with local $DEFINE as well)
>
> I implemented it.
>
>> Code: {$IF MyConst>1} ...
>
> This works now.
Pretty fast, thanks :-)
DoDi
More information about the Lazarus
mailing list