Главная страница


ru.linux

 
 - RU.LINUX ---------------------------------------------------------------------
 From : Serguei Miridonov                    2:5020/400     25 Mar 2005  22:03:42
 To : Eugene B. Berdnikov
 Subject : Re: Need GUI development tool (Kylix or something)
 -------------------------------------------------------------------------------- 
 
 
 Eugene B. Berdnikov wrote:
 
 > Serguei Miridonov <mirsev@cicese.mx> wrote:
 > SM> Мне кажется, что Вы ошибаетесь, поскольку определение "... так, как 
 > SM> считает нужным" неприменимо к языку, которым можно описать алгоритм 
 > SM> вычислений с жёстко заданной последовательностью.
 > 
 >  Можно, да. Расставив скобки. А если скобок нет - поведение не определено,
 >  фактически это значит, что компилятор имеет право поступать так, как
 >  захотели поступить его авторы.
 
 Только в том случае, если результат от порядка не зависит (см. ниже).
 
 >  Ссылки. Сначала - B.Straustroup, "The C++ Programming Language", 3d ed.,]
 >  Addson-Wesley, 1998.
 > 
 >  6.2.2 Evaluation order.
 > 
 >  The order of evaluation of subexpressions within an expression is undefined.
 >  In particular, you cannot assume, that expression is evaluated left to
 >  right. For example...
 >  [...]
 >  Parentheses can be used to force grouping. For example, a*b/c means
 >  (a*b)/c so parentheses must be used to get a*(b/c).
 
 Обратите внимание: "... a*b/c means (a*b)/c ..." И далее:
 
 >  Стандарт C++ (возможно, это тоже драфт). ISO/IEC 14882:1998(E)
 > 
 >  Во введении (раздел 1.9) достаточно ясно сказано:
 > 
 > [Note: operators can be regrouped according to the usual mathematical
 >        ^^^^^^^^^^^^^^^^^^^^^^^^^^
 >  rules only where the operators really are associative or commutative. 9)
 
 Вот здесь ключевая фраза: "only where the operators really are 
 associative or commutative". В случае же с double, float, complex, и 
 даже иногда с integer, как хорошо показано далее в примере, 
 operators _really_ are _not_ associative or commutative, т.е. в 
 реальных вычислениях ассоциативность и коммутативность не 
 обеспечиваются. А в таких случаях последовательность для этих 
 операций - слева направо, что и написано в стандарте языка, а также 
 проиллюстрировано в этом прекрасном примере:
 
 >  For example, in the following fragment
 > 
 >  int a, b; /*...*/
 >  a = a + 32760 + b + 5;
 > 
 >  the expression statement behaves exactly the same as
 > 
 >   a = (((a + 32760) + b) + 5);
 > 
 >  due to the associativity and precedence of these operators. Thus, the
 >  result of the sum (a + 32760) is next added to b, and that result is
 >  then added to 5 which results in the value assigned to a. On a machine
 >  in which overflows produce an exception and in which the range of values
 >  representable by an int is [Ѕ 32768,+ 32767], the implementation cannot
 >  rewrite this expression as
 > 
 >  a = ((a + b) + 32765);
 > 
 >  since if the values for a and b were, respectively, Ѕ 32754 and Ѕ 15,
 >  the sum a + b would produce an exception while the original expression
 >  would not; nor can the expression be rewritten either as
 > 
 >  a = ((a + 32765) + b);
 > 
 >  or
 > 
 >  a = (a + (b + 32765));
 > 
 >  since the values for a and b might have been, respectively, 4 and Ѕ 8
 >  or Ѕ 17 an d 12. However on a machine in which overflows do not produce an
 >  exception and in  which the results of overflows are reversible, the above
 >  expression statement can be rewritten by the implementation in any of the
 >                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 >  above  ways because the same result will occur. ]
 >  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 > 
 >  Hасчёт умножений и делений специальных примеров в тексте нет,
 >  хотя там такие же операции над полями порядка,
 >  но сам текст, по-моему, претендует на общность.
 > 
 >  Hу можно ещё упомянуть 5й раздел там же:
 > 
 >  5 Expressions
 > 
 >  4. Except where noted, the order of evaluation of operands of individual
 >  operators and subexpressions of individual expressions, and the order
 >  in which side effects take place, is unspecified [53].
 > --------------------------------------------------------------------
 > 
 >  В общем, из общей логики - неопределённое поведение для потребителя
 >  есть свобода действий для транслятора.
 
 Как раз с группировкой, ассоциативностью и коммутативностью - 
 свобода минимальна: только то тех пор, пока результат не отличается 
 от того, который получился бы при порядке вычислений 
 предопределённым стандартом.
 
 --- ifmail v.2.15dev5.3
  * Origin: CICESE Research Center, Ensenada, Mexico (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   23 Mar 2005 21:15:04 
 Re: Need GUI development tool (Kylix or something)   U.P.Galyuck   24 Mar 2005 17:10:10 
 Re: Need GUI development tool (Kylix or something)   Ilya Anfimov   24 Mar 2005 19:12:03 
 Re: Need GUI development tool (Kylix or something)   U.P.Galyuck   24 Mar 2005 20:06:19 
 Re: Need GUI development tool (Kylix or something)   Ilya Anfimov   25 Mar 2005 01:29:34 
 Re: Need GUI development tool (Kylix or something)   U.P.Galyuck   25 Mar 2005 17:56:18 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   25 Mar 2005 21:08:15 
 Re: Need GUI development tool (Kylix or something)   Eugene B. Berdnikov   26 Mar 2005 00:08:02 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   26 Mar 2005 02:12:40 
 Re: Need GUI development tool (Kylix or something)   Eugene B. Berdnikov   27 Mar 2005 04:08:25 
 Re: Need GUI development tool (Kylix or something)   U.P.Galyuck   30 Mar 2005 15:07:01 
 Re: Need GUI development tool (Kylix or something)   Ilya Anfimov   26 Mar 2005 00:49:32 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   24 Mar 2005 19:52:07 
 Re: Need GUI development tool (Kylix or something)   U.P.Galyuck   24 Mar 2005 20:23:58 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   24 Mar 2005 21:39:18 
 Re: Need GUI development tool (Kylix or something)   Eugene B. Berdnikov   25 Mar 2005 01:08:23 
 Re: Need GUI development tool (Kylix or something)   Ilya Anfimov   25 Mar 2005 01:31:35 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   25 Mar 2005 01:47:47 
 Re: Need GUI development tool (Kylix or something)   Eugene B. Berdnikov   25 Mar 2005 21:08:15 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   25 Mar 2005 22:03:42 
 Re: Need GUI development tool (Kylix or something)   Eugene B. Berdnikov   26 Mar 2005 00:08:02 
 Re: Need GUI development tool (Kylix or something)   Serguei Miridonov   26 Mar 2005 02:25:45 
 Re: Need GUI development tool (Kylix or something)   U.P.Galyuck   30 Mar 2005 15:07:02 
 Re: Need GUI development tool (Kylix or something)   Nick Voronin   30 Mar 2005 19:02:00 
 Re: Need GUI development tool (Kylix or something)   Dmitry Ponyatov   24 Mar 2005 21:22:00 
Архивное /ru.linux/13396dedf5000.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional