<div dir="ltr">On 13 February 2013 21:02, <span dir="ltr"><<a href="mailto:random832@fastmail.us" target="_blank">random832@fastmail.us</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On Sat, Feb 2, 2013, at 9:20, Steven D'Aprano wrote:<br>
> Unfortunately the proposal to use f{ ... } for frozen sets cannot work<br>
> within the constraints of Python's lexer:<br>
><br>
> <a href="http://mail.python.org/pipermail/python-3000/2008-January/011838.html" target="_blank">http://mail.python.org/pipermail/python-3000/2008-January/011838.html</a><br>
><br>
> Unfortunately we're running out of useful, easy to enter symbols for<br>
> literals. Until such time (Python4000 perhaps, or more likely Python5000)<br>
> as we can use a rich set of Unicode literals, I don't think there is any<br>
> clear way to have a frozenset literal.<br>
<br>
</div>I was going to post about not being sure what the objection is (if it's<br>
multiple tokens, let it be multiple tokens - the contents are multiple<br>
tokens anyway - and saying it would block a future syntax extension<br>
doesn't seem like a reasonable objection to a proposed syntax<br>
extension), but I had a new idea so I'll post that instead:<br>
<br>
{ as frozenset { ... } }<br>
<br>
The sequence "{ as" can't occur (to my knowledge) anywhere now. So, the<br>
thing after it is a keyword in that context (and only that context,<br>
otherwise "frozenset" remains an identifier naming an ordinary builtin)<br>
and specifies what kind of literal the following sequence is. You could<br>
also extend it to alternate forms for some other builtin types - for<br>
example { as bytes [1, 2, 3, 4, 5] } instead of b"\x1\x2\x3\x4\x5".<br>
Or... { as set { } }</blockquote><div><br></div><div style>I'm really not sure I like this idea, but surely:</div><div style><br></div><div style>LITERAL as KEYWORD</div><div style>{ ... } as frozenset</div><div style>
[1, 2, 3, 4, 5] as bytes</div><div style>{} as set</div><div style><br></div><div style>would work better.</div><div style><br></div><div style>However, I'm not happy on the idea that an identifier can be a keyword in another context.</div>
</div></div></div>