runway-compiler
runway-compiler copied to clipboard
clarify Set range
I think this example is underspecified:
- Is the size of the set 4 (22 - 25 inclusive)?
- If I push 5 distinct items, what happens?
- Why would I ever specify the range
[22..25]instead of[0..3]or[1..4]. Is the difference observable?
> var boolSet : Set<Boolean>[22..25];
> boolSet
{}
> push(boolSet, True);
> push(boolSet, False);
> boolSet
{False, True}
> push(boolSet, False);
> boolSet
{False, True}
It is underspecified. Given your use of the REPL, I think you've probably answered those questions for yourself already, but whether the Set type should behave that way is up for discussion.
The difference between 0..3 and 22..25 might be observable if you do:
for i, v in s {
print i
}
Though I don't know whether that's currently allowed or whether it should be.