[Python-3000] Set literal

Nick Coghlan ncoghlan at gmail.com
Sat Jan 26 06:03:42 CET 2008


Guido van Rossum wrote:
> On Jan 25, 2008 10:01 AM, Leif Walsh <adlaiff6 at gmail.com> wrote:
>> On Jan 25, 2008 12:37 PM, Christian Heimes <lists at cheimes.de> wrote:
>>> The pipe char is ambiguous because is no direction. It was suggested and
>>> rejected last year.
>> Out of almost-pure devil's advocacy, has <> been considered?  My first
>> instinct is that it would be ambiguous with less-than/greater-than,
>> but if someone can convince me otherwise, might it work?  After all,
>> it's the only other balanced pair of punctuation I see on my keyboard.
> 
> No, there are too many syntactic situations where this would make the
> grammar ambiguous or tortuous. We don't want to move beyond LL(1).
> (Apart from parsing indentation and nested parentheses, of course --
> which actually reminds me or another issue with using <> as brackets:
> the lexer can't know whether a particular < or > is used as a bracket
> or not, so it can't keep track of nesting like it does for (), [] and
> {}. So <> would always remain a second-class citizen.)
> 

Hmm, I guess both of those objections apply to using | as the delimiter 
as well. Ah well.

If anyone has a bit of free time to play with, it will probably be worth 
creating a retrospective PEP for the set literal syntax to capture the 
rationale for the various design decisions like:
   - why not || or <> as the delimeters?
   - why {} continues as the empty dict
   - why {1, 2, 3} is immutable, while {1:2} is not

Cheers,
Nick.


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list