Distinguish the keyword keyword

zhaozj2021-02-16  54

I have recently seen Li Wei's . Li Wei has the following function declaration in the first console program in the first chapter in the book:

Function WindowProc (Window: hwnd; wparam: wparam; lparam: lparam): LRESULT; stdcall;

I don't know if you think about a problem: in Delphi is not case sensitive, that is to say that the variable name and type name in the statement here. And when you study Pascal, C / C , the teacher often said to us can't say Go to the keyword as a variable name, why can you use it here?

I was confused when I first saw it, so I gave a DEPHI7 and finally found the answer: That is the difference between the reservoction (reserved word).

In : The Following Reserved Words Cannot Be Redefined or Used As Identifiers. That is to say, the keyword cannot be used as a variable name. The instructions for the reserved word in the book are as follows:

Directives are words that are sensitive in specific locations within source code. Deriectives have special meanings in the Delphi language, but unlike reserved words, appear only in contexts where user-defined identifiers can not occured.Heance-although it is inadvisable to do so-you The CAN Define An Identifier That Looks Exactly Like A Directive. That is to say that the retention word is used as a variable name.

This explains why WPARAM: WPARAM is allowed in the previous function declaration; this statement. By the way, Li Wei is in the "INSIDE VCL> book" Page 31 of the small word "C / C Builder" Better execution efficiency and use keyword message to assign window messages ... ", here the keyword should be changed to reserved words, because Message is a reserved word rather than a keyword. We are also reading the source code of VCL Often you can see the name of the mexage as a variable.

转载请注明原文地址:https://www.9cbs.com/read-27849.html

New Post(0)