Re: [Python-Dev] PEP 3103: A Switch/Case Statement

2006-06-29 Thread Eric Sumner
used to look up a value given its name, a dispatch table is used to look up a name given its value. The switch statement then lets you actually do something based on which name is returned. -- Eric Sumner ___ Python-Dev mailing list Python-Dev@pyt

Re: [Python-Dev] PEP 3103: A Switch/Case Statement

2006-06-29 Thread Eric Sumner
le objects and compiled switch statements. > who keeps track of them? Each construct keeps track of its own copies, and destroys them when they are no longer needed. -- Eric Sumner ___ Python-Dev mailing list Python-Dev@python.org http://mail.pyt

Re: [Python-Dev] PEP 3103: A Switch/Case Statement

2006-06-29 Thread Eric Sumner
atch > > table is defined. Each lookup is still O(1), so the whole operation > > remains O(1). > > what's a "label" ? In your example, RED, GREEN, and BLUE. colours provides a mapping from values to labels/cases, and the switch statement provides a mapping from la

Re: [Python-Dev] PEP 3103: A Switch/Case Statement

2006-06-29 Thread Eric Sumner
heck that all of the cases in the switch are defined in the dispatch table, but that only has to be done once per dispatch table/switch statement pair, and can then be stred in one or the other (probably the dispatch table, as that will be a proper object). -- Eric Sumner ___

Re: [Python-Dev] PEP 3103: A Switch/Case Statement

2006-06-28 Thread Eric Sumner
are defined (such as in a module). Programmers don't need to bother with making a dispatch table unless they are defining enumeration values themselves. -- Eric Sumner Note: I sent an email yesterday with a proposal to this effect, but it seems to have been lost. If anybody wants, I can r

[Python-Dev] Split switch statement

2006-06-27 Thread Eric Sumner
dispatcher is executed (in order) and their results are checked against the stored values. If no case (from the switch, not the dispatcher) matches, the switch's 'else' block is executed, if present. If more than one case (from the switch) matches, an exception is raised. Otherwise, t

Re: [Python-Dev] Temporary Constantification

2006-06-25 Thread Eric Sumner
e about the internals of Python (such as how long a check of a single variable takes relative to binding a new value to a name), I can't properly evaluate how much of a problem this would be. -- Eric Sumner ___ Python-Dev mailing list Python-Dev@pytho

[Python-Dev] Temporary Constantification

2006-06-25 Thread Eric Sumner
;m not able to actually assess the feasability or performance implications of this proposal, but I think it basically covers the problem. -- Eric Sumner ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo

Re: [Python-Dev] Switch statement

2006-06-23 Thread Eric Sumner
purpose and use. Again, I concur. My point was not that the mechanics of the construct were incorrect, but that the proposed syntax misrepresented its function. Again, I am sorry if I was unclear about this. -- Eric Sumner ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Re: [Python-Dev] Switch statement

2006-06-23 Thread Eric Sumner
suite This is consistent with parameter lists, which emphasizes that the sequences are being enumerated instead of simply tested against. -- Eric Sumner ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python

Re: [Python-Dev] Switch statement

2006-06-23 Thread Eric Sumner
at precomputation time. How does this interact with __contains__, __len__, and __iter__ for the 'case in S' statement? Would it work with a class that only implements __contains__, such as a continuous range class? -- Eric Sumner ___ Python

Re: [Python-Dev] PEP 343: Context managers a superset of decorators?

2006-02-13 Thread Eric Sumner
On 2/13/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Eric Sumner wrote: > > I realize that I made an assumption that may not be valid; > > namely, that a new scope is generated by the 'with' statement. > > The with statement uses the existing scope - its just

Re: [Python-Dev] PEP 343: Context managers a superset of decorators?

2006-02-13 Thread Eric Sumner
On 2/12/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: [paragraphs swapped] > The desire for context managers to have access to its enclosing scope is > another discussion entirely, though it may do so without express > permission via stack frame manipulation. My main point was that, with relativel

[Python-Dev] PEP 343: Context managers a superset of decorators?

2006-02-12 Thread Eric Sumner
er of these suggestions would be to implement, or if it would be a good idea to do so. At this point, they are just something to think about -- Eric Sumner ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/pytho