8000 Ambiguous symbol table names · Issue #121914 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Ambiguous symbol table names #121914
Open
Open
@serhiy-storchaka

Description

@serhiy-storchaka

Feature or enhancement

Every symbol table has type and name. The name of the symbol table that corresponds a class or a function is the same as the name of the corresponding class or function. But there are special symbol tables of type function for lambdas and generator expressions (there were also symbol tables for comprehensions, but they are no longer used). For lambdas. the name "lambda" does not conflict with other function names, because it is a reserved word. But for general expressions, the name "genexpr" can conflict with local function "genexpr" (see #119698). It is possible to distinguish the symbol table corresponding to a generator expression by looking in the list of its parameters, but this is not so convenient.

I propose to make the difference more clear:

  • Either use separate types for lambda and generator expression symbol tables.

  • Or use names which cannot be confused with any function name:

    • reserved word like lambda. But I do not know good variant for generator expression.
    • hyphenated word, like gen-expr.
    • angle brackets, like <genexpr> and <lambda>.
    • other special characters, e.g. .genexpr.

    Names of symbol tables of other types like top and __annotations__ can also be changed for uniformity and to avoid possible future conflicts.

The original issue #119698 was solved in other way, so there is no urge for such change. This is just a wild idea.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0