Use of frozenset and frozendict in the manual #551
Replies: 1 comment 5 replies
-
|
Hi Alexander, Thank you for the kind words. We also felt that a concise reference manual was missing. I now see that our code is not optimal for the common-case scenarios. When I was writing the python examples, I was thinking about the most general case. You have a point about simplifying the examples. Although I would like to keep the general ones too, how about adding the examples that you have in mind as a starter? You could give your examples under the assumption about the type of a data structure, e.g., As for Best regards, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Thank you for writing the TLA+ Language Manual for Engineers, I think it's a great resource and I was really missing something like this! To look up syntax I often reached for https://learntla.com/tla/ which was never intended as a reference.
I also like the idea of the Python examples a lot, but the use of frozenset and frozendict spoils it a bit for me. For example what could be very similar code
{ 1 } - { 1 } == { "a" } - { "a" }now becomes the noisy
Also the frozendict examples don't run without a dependency which does not work on recent Python versions.
Generally I think the examples would benefit from making the analogy a bit more liberal, does it really matter if we iterate over a
range(1, 4)or afrozenset({ 1, 2, 3 })in Python?For example
Could be
{ n: { i: n + i for i in range(1, n + 1) } for n in range(1, 4) }[3][2] # 5I'm aware that there are some examples which have sets in sets, in these cases we could keep frozenset in the necessary places, like
{ frozenset({1}) } - {1, 2}instead offrozenset({frozenset({1})}) - frozenset({1, 2}).If you think that this is a good idea, I wouldn't mind converting the examples.
Beta Was this translation helpful? Give feedback.
All reactions