Should use of _ as an R-value be deprecated?
PEP 622 proposes a special use for _: to match anything, discarding the whatever value matches. (If I understand.) This aligns with the way _ is conventionally used in other statements. This special use in case statements feels weird given that _ is otherwise just an ordinary variable. It may even have a value going into the case/match statement, which would be ignored. Has there been any discussion on deprecating use of _ as an R-value? In other words, making _ a "black hole" variable "preposition" into which values go but never come out? Besides the benefit of unifying the conventional use of _ with its proposed use in case/match statements, another benefit for CPython would be that _ would no longer hang onto references and would therefore not prevent garbage collection of whatever was put into it. Best, Neil
Oh, I guess there's gettext… On Monday, June 29, 2020 at 5:04:05 AM UTC-4, Neil Girdhar wrote:
PEP 622 proposes a special use for _: to match anything, discarding the whatever value matches. (If I understand.) This aligns with the way _ is conventionally used in other statements. This special use in case statements feels weird given that _ is otherwise just an ordinary variable. It may even have a value going into the case/match statement, which would be ignored.
Has there been any discussion on deprecating use of _ as an R-value? In other words, making _ a "black hole" variable "preposition" into which values go but never come out? Besides the benefit of unifying the conventional use of _ with its proposed use in case/match statements, another benefit for CPython would be that _ would no longer hang onto references and would therefore not prevent garbage collection of whatever was put into it.
Best,
Neil
participants (2)
-
Neil Girdhar
-
Steven D'Aprano