28.04.2008, 19:05 | #1 |
Участник
|
mfp: What's up with this semicolon?
Источник: http://blogs.msdn.com/mfp/archive/20...semicolon.aspx
============== The most visual idiosyncrasy in X++ is the dangling semicolon separating the variable declarations from the actual code. But why is it there and why is it needed? Best practices in X++ (as in most other modern languages) suggest using TitleCase when declaring (and referring to) types, and using camelCase when declaring variable types. Here is an example of what an X++ developer could write: AccountNum accountNum; ; accountNum = "4000"; As X++ (unlike most other modern languages) is case insensitive, this is what the compiler will see: accountnum accountnum; ; accountnum = "4000"; Suppose the dangling semicolon wasn't there. Then the "accountnum" statement in the second line is ambigious. It could either refer to the type or to the variable. The X++ compiler assumes it is the type, and thus generates a compilation error when encountering the equal (=) sign; as you cannot assign into a type. By inserting the dangling semicolon you instruct the compiler that there will be no more variable declarations; and thus "accoutnum" is a reference to the variable and not the type. If it was made a priority to get rid of dangling semicolons, what could be done?
This morning I have created a package with my findings and sent it to the X++ team for evaluation. This change will not make it into AX 2009; but I'm confident those of us writing X++ code at Microsoft will enjoy this very soon. The rest of you will have to wait for AX6.0. ============== Источник: http://blogs.msdn.com/mfp/archive/20...semicolon.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|