Differentiate Reserved Words and keywords

Source: Internet
Author: User

Li Wei's <inside VCL>. The first console in the first chapter of the book contains the following function declaration:

Function windowproc (window: hwnd; amessage: uint; wparam: wparam; lparam: lparam): lresult; stdcall; export;

I don't know if you have thought of a problem. In Delphi, It is case-insensitive. That is to say, the variable name and type name in the Declaration are the same. when we were learning Pascal, C/C ++, the teacher often told us that we could not use keywords as variable names. Why can we use them here?

I was confused when I saw this, so I checked dephi7's <Delphi language guide> and finally found the answer: the difference between the reserved words and the keywords (Reserved Words.

As mentioned in <Delphi language guide>, the following reserved words cannot be redefined or used as identifiers. That is to say, keywords cannot be used as variable names. The description of reserved words in the book is 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 cannot occured. heance-although it is inadvisable to do so-you can define an identifier that looks exactly like a directive. that is to say, reserved words can be used as variable names.

This explains why WParam: WPARAM; is allowed in the previous function declaration. by the way, Li Wei explained on the 31st page in the book <Inside VCL> that "C/C ++ Builder uses the keyword message to distribute window messages for better execution efficiency.... ", the keyword here should be changed to reserved words, because Message is reserved words rather than keywords. when we read the source code of VCL, we can often see that Message is used as the variable name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.