Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we remove brackets from range syntax? #445

Closed
athas opened this issue Dec 21, 2017 · 6 comments
Closed

Should we remove brackets from range syntax? #445

athas opened this issue Dec 21, 2017 · 6 comments

Comments

@athas
Copy link
Member

athas commented Dec 21, 2017

I have realised that there is no syntactic reason to require brackets around a range literal:

[1...10]

We might as well write it as:

1...10

There is no ambiguity. Swift does it this way. Should we, too? It is mostly a question of whether the brackets make it clear that an array is being produced. Due to the low operator priority of ..., many uses will still require parentheses:

map f (1...10)

But others will not:

loop x for i in 1...10 do ...

By a quick search in the benchmarks repository, we have 21 uses of range literals, and 11 of these will not require parentheses.

@RasmusWL
Copy link
Contributor

I think it would be nice to keep them, not based on anything but my personal opinion

@athas
Copy link
Member Author

athas commented Dec 21, 2017

It appears that most languages (Rust, Swift, Ruby) use a notation without brackets. Haskell seems a bit like the odd man out.

@Qata
Copy link
Contributor

Qata commented Dec 22, 2017

+1, there’s no need for them

@melsman
Copy link
Contributor

melsman commented Dec 22, 2017 via email

@athas
Copy link
Member Author

athas commented Jan 10, 2018

I will remove the brackets once the block is over, so no student projects run into a sudden syntax change.

@athas
Copy link
Member Author

athas commented Jan 28, 2018

The block is over; change incoming.

athas added a commit that referenced this issue Jan 28, 2018
athas added a commit that referenced this issue Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants