Skip to content

Differentiate LvalueTuple from expression TupleExpr (refactoring) #2123

Closed

Description

@elazarg

(Apologies in advance if I am explaining the obvious)
In the expression

(a, b) = (b, a)

The left side is an lvalue and the right side is not. The two concepts have only so much in common. If a TupleExpr makes its way where an LvalueTuple belongs, that's a bug. It's also a bug in the other way around (unlike in some programming languages). This distinction appears in the AST as a Load/Store distinction, and it should be expressed in node.py too.

This distinction needs to be accompanied with the general distinction of lvalue nodes (i.e. a dedicated unifying type, instead of a comment) for targets in for, with etc.. However, I don't think that a dedicated LvalueName is helpful since it refers to the same entity as NameExpr. It is not the case with tuples; LvalueTuple is more of a pattern-matching construct than an expression.

The should not be a distinction between LvalueTuple and LvalueList. since the language does not have this distinction (e.g. [a, b] = (b, a) is valid)

I think that it will make the code clearer, better documented, better checked and with less isinstance tests and casts sprinkled around; in some cases, I think that these tests will be replace by an accept() call.

Activity

  1. elazarg commented on Sep 12, 2016

    @elazarg
    ContributorAuthor

    Related: Issue #1783, PR #1785, PR #2121 and PR #2122

  2. gvanrossum commented on Sep 12, 2016

    @gvanrossum
    Member
  3. gvanrossum commented on Sep 28, 2016

    @gvanrossum
    Member

    Let's just close this since we didn't ask for this refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions