yoy.be "Why-o-Why"

TIL: 'method modifiers' are not reserved words.

2017-01-05 21:17  TILdirrw  coding delphi  [permalink]

Thing I learned today: 'method modifiers' are not reserved words. Apparently the Object Pascal parser 'consumes' these as labels that just happen to be there or not. Which means in other contexts they're free to use as identifiers, and so they're not reserved words... Strange but OK I guess as this keeps the tokenizer that does its job right before the parser, a little smaller... (How I stumbled upon this is a different story altogether, but one I may be sharing sometime soon...) I searched the documentation a bit and there they're called directives: Fundamental Syntactic Elements: Directives which I thought were things like {$XXX+}, but those are compiler directives...

So these variable names are accepted by the parser/compiler (it doesn't mind the smell at all):

procedure test;
var
stdcall,safecall,cdecl,overload,dynamic,register,abstract,reintroduce:integer;
begin
stdcall:=1;
safecall:=11;
cdecl:=111;
//...
end;

twitter reddit linkedin facebook