AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 26.06.2007, 08:00   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
Issues concerning X++: Operator precedence of && and ||
Источник: http://blogs.msdn.com/x/archive/2007...ce-of-and.aspx
==============

There is an issue concerning logical expressions (i.e. expressions that are evaluated to true or false, a.k.a Boolean expressions) in X++. The essence of this issue is that the X++ language is not aligned with other languages in its precedence of the logical and (&&) and or (||) operators. In X++ these two operators have the same precedence, whereas in other languages && is higher priority than ||.

The issue here is that programmers might unexpectedly create bugs for themselves when writing complex Boolean expression involving these two operators. For instance:

A || B && C

(where A, B and C are Boolean subexpressions) will be evaluated as (A||B) && C in X++, but as A || (B && C) in every other languages that I know of.

This unfortunate operator priority choice has been there since the first version of the X++ language. The workaround, of course, is simple (use parenthesis to group together the sub-expressions), but there is a potential for bugs that may be subtle. We have had no reports from the user base about this problem. It is unclear to me at this time if this is explicitly called out in any documentation that we have, but I doubt it.

The morale is this: Always group together your complex Boolean expressions with parenthesis to aid both you and the compiler.

We have been very reluctant to align the precedence of the logical operators to other languages, because we fear breaking existing code in the user code base. I would love to hear the opinions of the people out there in the trenches. Let us know: Do we let sleeping dogs lie, or go ahead and fix it?


Источник: http://blogs.msdn.com/x/archive/2007...ce-of-and.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axStart: Why performance issues hits you’re AX implementation 3 months after going live. Blog bot DAX Blogs 0 05.03.2008 05:47
Dynamics AX: Microsoft Dynamics AX (DAX): Known Issues when upgrading to Microsoft Dynamics™ AX 4.0 - Arijit Basu | AX MVP Blog bot DAX Blogs 0 31.05.2007 03:30
Arijit Basu: Known Issues when upgrading to Microsoft Dynamics™ AX 4.0 Blog bot DAX Blogs 0 29.05.2007 15:10

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 15:59.