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

2012/2/24 Jonas Maebe <jonas.ma...@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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to