A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/066196.html below:

[Python-Dev] Switch statement

[Python-Dev] Switch statementPhillip J. Eby pje at telecommunity.com
Mon Jun 19 05:59:21 CEST 2006
At 06:56 PM 6/18/2006 -0700, Josiah Carlson wrote:
>The non-fast version couldn't actually work if it referenced any names,
>given current Python semantics for arbitrary name binding replacements.

Actually, one could consider "case" expressions to be computed at function 
definition time, the way function defaults are.  That would solve the 
problem of symbolic constants, or indeed any sort of expressions.

An alternate possibility would be to have them computed at first use and 
cached thereafter.

Either way would work, and both would allow multiple versions of the same 
switch statement to be spun off as closures without losing their "constant" 
nature or expressiveness.  It's just a question of which one is easier to 
explain.  Python already has both types of one-time initialization: 
function defaults are computed at definition time, and modules are only 
loaded once, the first time you import them.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4