Skip to content

Change symbol for inclusive range (...) to keyword to to disambiguate from open range (..), and change ranged for to use inclusive ranges #17784

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

Closed
expikr opened this issue Oct 30, 2023 · 2 comments

Comments

@expikr
Copy link
Contributor

expikr commented Oct 30, 2023

current:

usage a.. a..b a...b
switch no no yes
ranged for no yes no
indexed for yes yes no
slice yes yes no

proposed:

usage a.. a..b (a to b)
switch no no yes
ranged for no (no) (yes)
indexed for yes (no) no
slice yes yes no

Since ranged for do not permit unbounded ranges, there is no reason to use a syntax that allows it.

switch(a) {
    0 to 10 => {
        // top ten
    },
    69 => {
        // nice
    },
    else => {
        if(a<100} {
            // inside ranking
        } else {
            // outside ranking
        }
    },
}

for(0 to 10) {
    // 11 steps executed
}

for(items, 0..) |item, i| {
    // iterate all
}

for(items[2..9], 10..) |item, i| {
    // item[2] , 10
    // item[3] , 11
    // etc
}
@BratishkaErik
Copy link
Contributor

See #359 (comment)

@andrewrk
Copy link
Member

Not interested in language proposals

@andrewrk andrewrk closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants