rakitzis / rc

rc shell -- independent re-implementation for Unix of the Plan 9 shell (from circa 1992)
Other
252 stars 23 forks source link

Lack of `continue` #25

Closed CasperVector closed 6 years ago

CasperVector commented 8 years ago

return and break have been reintroduced into this neat rc implementation. May I request to also add continue? This can be really helpful for some constructs.

TobyGoodwin commented 8 years ago

Thanks for the input. Do you have a short yet compelling example? :smile:

Offhand, it looks to me like

while (condition) {
    ... stuff ...
    if (something)
        continue;
    .... more stuff ..
}

can always be replaced by

while (condition) {
    ... stuff ...
    if (!something) {
        ... more stuff ...
    }
}
CasperVector commented 8 years ago
loop {
    stuff1 ...
    cond1 || continue
    stuff2 ...
    cond2 || continue
    ...
}

(Similar constructs also occur with return and break :)

borkovic commented 8 years ago

Two reasons I'd vote to add continue:

I have an implementation of continue in my repository. If there is a consensus for adding it, I'd be glad to post it for a pull.

TobyGoodwin commented 7 years ago

@borkovic I'd be very interested to see your implementaton. Can you turn it into a pull request?

borkovic commented 7 years ago

I am out of town. I'll try to do it over the weekend.

On Fri, Aug 25, 2017 at 12:44 PM Toby Goodwin notifications@github.com wrote:

@borkovic https://github.com/borkovic I'd be very interested to see your implementaton. Can you turn it into a pull request?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rakitzis/rc/issues/25#issuecomment-325018346, or mute the thread https://github.com/notifications/unsubscribe-auth/AMYWdVyldshL9bh6PtLh1FLX2p38vr4Oks5sbyQ4gaJpZM4JrtJE .

TobyGoodwin commented 7 years ago

Thanks, looks great! (I particularly like the new assert() in unexcept()) I've pushed a branch called continue to the main github repo, in case other people want to play with it. I'll merge this into master in the next few days unless anyone objects.

borkovic commented 7 years ago

Glad to contribute.

Interesting that you like assert() in unexcept(): I was not sure whether to make 'continue' change alone or to include assert()+unexcept() as well.

On Mon, Aug 28, 2017 at 12:51 PM, Toby Goodwin notifications@github.com wrote:

Thanks, looks great! (I particularly like the new assert() in unexcept()) I've pushed a branch called continue to the main github repo, in case other people want to play with it. I'll merge this into master in the next few days unless anyone objects.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rakitzis/rc/issues/25#issuecomment-325460424, or mute the thread https://github.com/notifications/unsubscribe-auth/AMYWdaSKvAGXyCwHFQUav-OjQ_-hGAE-ks5scxpNgaJpZM4JrtJE .

TobyGoodwin commented 6 years ago

merged