On 2022-01-21 00:18, Cameron Simpson wrote:
Well, I've just waded through this discussion.

This all feels to me like a special case of "wanting a constant for
bytecode".  What is we had a "freeze" operator, eg:

     |foo|

which would produce a frozen version of foo. I'm liking the vertical
bars myself, I think because it feels vaguely slightly analogous to
"absolute value". So (assuming we can squeeze it into the expression
syntax):

     |{1,2,3}|

always makes a direct frozen set on the same basis that:

     x in {1,2,3}

directly makes a frozenset by expression inspection. Then

Paired with a __freeze__ dunder method, this applies to any type, not
just sets. (Where appropriate of course.)

So:

     |{1,2,3}|       frozen set
     |[1,2,3]|       tuple!
     |any-iterable|  tuple!
     |{1:2, 3:4}|    frozen dict

Ths saves us (a) inventing a special syntax for frozen sets and (b)
gateways to freezing many things, starting with the obvious above, via
the __freeze__ dunder method.

This feels more general and less bikeshedable.

My main question is: is the syntax unambiguous?

I don't know whether it's unambiguous, but it could be confusing.

For example, what does this mean:

    | a | b |

?

It's:

    | (a | b) |

I think.

The problem is that '|' could be an opening '|', a closing '|', or an infix '|'.

You don't get this problem with differing open and closing pairs such as '(' and ')'.
_______________________________________________
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/ZU24ILSJLN4U6XGYAOP6RVGDQ7XOAWAO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to