On 11/21/2013 10:06 AM, Martin Schreiber wrote:
> that semantic is independent of order of items. With variable case 
> labels this is not possible.

I don't understand what you mean by this. Could you give an example ?

Of course non-constants lead to additional logical problems. If a case 
label in fact is a function call, it could have side-effects that affect 
the selection of the other candidates.

But this is true for many other syntax elements, as well.

E.g. boolean operands are not evaluated if not necessary:


function b: Boolean;
function c: Boolean

var a : Boolean

  a := b and c;

Here, c might have a side effect but is not (necessarily) evaluated if 
the result of b is false. (At least this is how I understand most syntax 
definitions are done: evaluation from left to right.)

This this user code is erroneous if c has side effects.

Moreover in case of site effects the statements

   a := b and c.
and
a := c and b.

are not equivalent. (Obviously again: This this user code is erroneous 
if b or c have side effects. )



Same of course holed for case: it is to be evaluated from left to right 
(i.e. from top to bottom).

For me, the "case a of" syntax should be just an abbreviation of an 
"else if" cascade of

if a=x1 then begin
  ...
  end else if a = x2 then begin
  ...
  end else if a = x2 then begin
  ...
  else begin
end;

In what low level operations this results is up to the compiler 
optimizations. (Martin: Happy coding ! :-) )

If there are side-effects within the evaluation of the decision-terms, 
is is obviously possible that some re not evaluated. The compiler needs 
to be able to rely on this fact and thus any user code that violates 
this rule needs to be considered as erroneous (see the boolean example 
above).

Of course the order of the blocks might change the behavior. Either the 
compiler needs to take this into account, or it needs to be defined that 
any user code that relies on the order needs to be considered (and 
documented) as erroneous (see the boolean example above)

-Michael

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to