On 2022-01-16 00:27, Steven D'Aprano wrote:
It seems to me that all of the machinery to make this work already
exists. The compiler already knows how to create frozensets at
compile-time, avoiding the need to lookup and call the frozenset()
builtin. All we need is syntax for a frozenset display.

How does this work for you?

     f{1, 2, 3}

I don't like that syntax. In the first place, as others have noted, it treads too close to existing function-call and indexing syntax. In those syntaxes, `f` is a name, whereas here it is not a name but just a syntactic marker (as in f-strings).

In the second place, I don't like the idea of using prefixes to change the types of objects like this. As far as I know we only have one example of that, namely byte strings. The other string prefixes do not create different types, they just affect how the literal is eventually parsed into a string.

I would prefer some sort of augmented bracket notation, like {:1, 2, 3:} or something along those lines.

I do think it would be nice to have a frozenset literal, because I'm a purity-beats-practicality person and it bugs me that there isn't one. However, from that perspective I'd much rather have a frozen-dict type and then a syntax for it. :-)

--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
   --author unknown
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/YE4NC7YTZNIFSGUGMUMGVR2IBT2A7B5W/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to