[fpc-pascal] Re: Class const of array of record.

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Feb 28 13:47:59 CET 2012


On 28 Feb 2012, at 13:25, Everton Vieira wrote:

> 2012/2/24 Jonas Maebe <jonas.maebe at elis.ugent.be>
>
>> On 24 Feb 2012, at 18:07, Everton Vieira wrote:
>>
>>> static; should be a keyword, doesn't?
>>
>> No, it's not a keyword.
>
> But is used like one. Why is that so?

It's not used like one. Keyword means "it's a reserved word by the  
language, and you can never use it for anything other than how it's  
defined by the language". Examples of keywords are "begin" and  
"procedure". Some identifiers are only keywords in certain language  
modes (e.g. try/except/on/finally/raise are only keywords in language  
modes that know about exception handling).

There are other identifiers that can have a special meaning in a  
particular context (such as "cdecl" and "static"), but outside that  
context they behave like any other modifier. Or they may simply be  
types or routines that are part of the system unit. The reason is that  
code written for language dialects that do not treat those identifiers  
as keywords can otherwise not be compiled. To illustrate:

{$mode objfpc}

type
   longint = string;
   cdecl = longint;
   protected = longint;
   varargs = char;
   sin = byte;

var
   stdcall: cdecl;

// note that the final "cdecl;" here does have the "original" meaning  
of cdecl
function static(const inline: protected): varargs; cdecl;
begin
   static:=stdcall[sin(inline[1])];
end;

begin
end.


Jonas




More information about the fpc-pascal mailing list