Python 3000 idea: reversing the order of chained assignments

Steve Holden steve at holdenweb.com
Thu Mar 22 11:23:25 EDT 2007


Duncan Booth wrote:
> Steve Holden <steve at holdenweb.com> wrote:
> 
>> Help me out here. It looks as though the real syntax should 
>> be something like
>>
>> assignment_stmt       ::=       (target_list "=")+ expression_list |
>>                                  (target_list "=")+ assignment_stmt
> 
> That is precisely the point. If it was:
> 
> assignment_stmt       ::=       (target_list "=") expression_list |
>                                  (target_list "=") assignment_stmt
> 
> (i.e. removing the '+' which your eyes jumped over)
> then the actual assignments would have to apply right to left with each 
> assignment giving the result for the next one.
> 
> But since it is:
> 
> assignment_stmt       ::=       (target_list "=")+ expression_list
> 
> the repeated target lists may be expected, and are indeed defined, to 
> assign left to right.

Thanks, I see the plus sign now and appreciate that it indicates "one or 
more of", so the syntax is correct. But syntax doesn't imply semantics, 
so a left-recursive or right-recursive syntax formulation wouldn't 
require any change to the semantics of assignment.

In other words,

assignment_stmt       ::=       (target_list "=") expression_list |
                                  (target_list "=") assignment_stmt

and

assignment_stmt       ::=       (target_list "=") assignment_stmt |
                                  (target_list "=") expression_list

are entirely equivalent, and neither imply any order of execution. I'm 
sure you understand that syntax only specifies what's legal, not how it 
should be interpreted.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb     http://del.icio.us/steve.holden
Recent Ramblings       http://holdenweb.blogspot.com




More information about the Python-list mailing list