--* From smwatt@spadserv.watson.ibm.com Thu Oct 21 07:24:06 1993 --* Received: from spadserv.watson.ibm.com by radical.watson.ibm.com (AIX 3.2/UCB 5.64/900524) --* id AA25179; Thu, 21 Oct 1993 07:24:06 -0400 --* Received: by spadserv.watson.ibm.com (AIX 3.2/UCB 5.64/900524) --* id AA20514; Thu, 21 Oct 1993 07:32:05 -0400 --* Date: Thu, 21 Oct 1993 07:32:05 -0400 --* From: smwatt@spadserv.watson.ibm.com (Stephen Watt) --* X-External-Networks: yes --* Message-Id: <9310211132.AA20514@spadserv.watson.ibm.com> --* To: asbugs@radical.watson.ibm.com, bronstei@inf.ethz.ch, peteb@yorktown, --* santas@inf.ethz.ch, smwatt@watson.ibm.com --* Subject: Multiple value assignment bug --@ Fixed by: PI Fri Jan 13 09:07:50 EST 1995 --@ Tested by: none --@ Summary: Fixed the code generation for multiple assignments. Now prints '1,2,2,4'. > From: Philip Santas > Date: Wed, 20 Oct 93 23:57:22 +0100 > To: bronstei@inf.ethz.ch, smwatt@watson.ibm.com > Subject: Re: A# code > > > Does the code > (a, b) := (b, ncrem(a, b)) > have the same semantics as: > > c:=a > a:=b > b:=ncrem(c,b) > ? > > Are tuples evaluted from left to right? > What if we had: > > (a,b) := ((a,b):=ncrem(a, b);b, ncrem(a, b)) > ? > a > I ask, because the code: > > ------------------------------------------------------- > (a:SI, b:SI) := (1,2) > > print(a)()(b)() > > (a,b) := ({{(a,b):=(a+1, b+1)}; a}, {{(a,b):=(a+1, b+1)}; b}) > print(a)()(b)() > ------------------------------------------------------ > returns: > > 1,2,3,4 > > where I was initially expecting it to return: > 1,2,2,4 > > Philip The order of evaluation in multiple values is implementation dependent. I.e. it could be left-to-right or right-to-left or some other order. In a multiple value assignment, all rhs are evaluated before any lhs are updated. Nevertheless, your code does illustrate a different bug: It should print either 1,2,2,4 or 1,2,3,3 but not 1,2,3,4.