Issue 12635: use "as" for block scope support (original) (raw)

Issue12635

Created on 2011-07-25 07:36 by lyricconch, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg141076 - (view) Author: HaiYun Yan (lyricconch) Date: 2011-07-25 07:36
use "as" for block scope support just like mozilla javascript "let" extension https://developer.mozilla.org/en/new_in_javascript_1.7#Block_scope_with_let_%28Merge_into_let_Statement%29 usage: as_clause(as_declare): "as" NAME as_stmt: NAME "as" test as_expr: "(" expr "as" NAME ")" expr var declare by as_clause is alive in only eg: <NAME "f" binding saved>with open(...) as f<NAME "f" bind to HEAPObj>: ... <NAME "f" binding restored> the same rule to "except E as e: " spec: from socket import AF_INET as IPv4 <IPv4 bind to socket.AF_INET slot> IPv4 = None assert socket.AF_INET == None var in as_stmt is alive in current indentation eg: for i in range(10): <NAME "t" binding saved> t as f()+1 <NAME "t" bind to f()+1> ... <NAME "t" binding restored> var in as_expr is alive in sub expr only eg: t = None x = (2+3 as t) t**2 assert t == None ane x == 25 Suggestion: new opcode ENTER_BLOCK #depth #varslots
msg141077 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-07-25 09:02
You should propose this to the python-ideas mailing list first. It might be worth checking the archives of the ML as well -- I think I saw already something similar a while ago.
History
Date User Action Args
2022-04-11 14:57:20 admin set github: 56844
2011-07-25 09:02:47 ezio.melotti set status: open -> closednosy: + ezio.melottimessages: + resolution: rejectedstage: resolved
2011-07-25 07:36:47 lyricconch create