runway-compiler icon indicating copy to clipboard operation
runway-compiler copied to clipboard

clarify Set range

Open joelburget opened this issue 9 years ago • 1 comments

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}

joelburget avatar Jul 06 '16 15:07 joelburget

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.

ongardie-sfdc avatar Jul 21 '16 18:07 ongardie-sfdc