Guido van Rossum wrote: > So, my proposal is to give up on static, accept PEP 3103 with the > following options: > - Syntax alternative 2+B (unindented cases, 'case in ...' for multiple > cases). > - Semantics option 3 (def-time freezing)
I agree with giving up on static, or at least treating it as a separate issue from switch. But there's one more thing I'd like to see discussed concerning def-time freezing: apple = 1 banana = 2 def f(): ... def g(fruit): ... switch fruit: case apple: ... case banana: ... With def-time freezing as currently proposed, this will evaluate the cases inside g() every time f() is called. But that would be wasteful, because they only depend on names defined at the module level. So I'd like to propose that "def time" be modified slightly to mean "def time of the outermost function that is still inside the scopes containing all the names that the case expressions depend on". Not sure about the wording of that, but I hope you get the idea. In the above example, that would be the def time of f(), rather than g(). I'd further suggest that a switch be allowed to reference names in the current scope, in which case no optimisation is done. That would take care of switches at the module level, without making the module level a special case with respect to the evaluation time rules. -- Greg _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com