[fpc-pascal] New feature: IfThen() intrinsic
Sven Barth
pascaldragon at googlemail.com
Mon Feb 1 15:42:47 CET 2016
Am 01.02.2016 13:29 schrieb "Michael Van Canneyt" <michael at freepascal.org>:
>
>
>
> On Mon, 1 Feb 2016, Maciej Izak wrote:
>
>> 2016-02-01 13:09 GMT+01:00 Michael Van Canneyt <michael at freepascal.org>:
>>>
>>>
>>> No. The compiler already uses &.
>>>
>>> & means 'the following is an identifier even if it is a keyword'.
>>>
>>> You can perfectly declare and compile:
>>>
>>> Var
>>> &if : integer;
>>>
>>> begin
>>> &if:=1;
>>> end.
>>>
>>> So &if is a bad idea.
>>
>>
>>
>> Yes it is possible. Anyway it is better idea than IfThen. You treat facts
>> selectively. How often is used &if and how often is used IfThen?
>
>
> You missed my point.
>
>
>>
>> &IfThen looks also good (I like shorter syntax &if). With "&" prefix it
is
>> obvious that this function is unique.
>
>
> You misunderstand.
>
> The & character cannot be used as part of an identifier, it is a special
token.
>
> It is eaten by the scanner. The parser will never see it. You simply
cannot define "&if' as an identifier. The parser will always see 'if'.
>
> scanner.pas around line 4607.
>
> And modifying the scanner for this exception is a REALLY bad idea.
Maciej is in so far right that the intrinsic could indeed be named "if" and
the only way to call it would thus be by "&if", cause only then the scanner
would not treat "if" as a keyword. So it would work with what the compiler
currently can.
I'm more inclined to use iif() however, as &if() doesn't look that nice...
(though it would be more noticeable :P )
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160201/3feca011/attachment.html>
More information about the fpc-pascal
mailing list