Saturday, October 3, 2009

Delphi ampersand operator

Did you know that you can declare keywords as identifiers in Delphi 2010 using the ampersand(&) operator before the keyword?
  type: Integer;
the above example is iilegal but in Delphi 2010 you can use
  &type: Integer; (* Delphi is OK with this and will compile! *)
Source Delphi help
The & prevents a keyword from being parsed as a keyword (that is, a reserved word). If you encounter a method or type that is the same name as a Delphi keyword, you can omit the namespace specification if you prefix the identifier name with an ampersand. But when you are declaring an identifier that has the same name as a keyword, you must use the &.
I personally love the idea, let me know what you think about it.

No comments:

Post a Comment

Blogroll(General programming and Delphi feeds)