Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

clarify Set range #9

Open
joelburget opened this issue Jul 6, 2016 · 1 comment
Open

clarify Set range #9

joelburget opened this issue Jul 6, 2016 · 1 comment

Comments

@joelburget
Copy link

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}
@ongardie-sfdc
Copy link
Collaborator

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants