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

Add do shorthand for loops (and maybe more?) #12

Open
ecton opened this issue Feb 14, 2024 · 0 comments
Open

Add do shorthand for loops (and maybe more?) #12

ecton opened this issue Feb 14, 2024 · 0 comments

Comments

@ecton
Copy link
Member

ecton commented Feb 14, 2024

To avoid blocks in some cases, we've allowed some shorthands. The primary example is if a then b as an alternative to if a { b }

I'm rethinking the choice of then in that situation, and thinking that maybe we should use the do keyword in if as well as in loops and other locations where it makes sense.

if a do something();

while condition() do something();

for x in expr do something(x);

try something() catch => handle_error(it);
try something() catch do handle_error(it);

The try example at the end shows how the current "fat arrow" syntax already makes its syntax concise. This proposal may be to make do valid wherever the fat arrow is. However, the fat arrow is not as flexible... if a => b else c looks weird to me, but if a do b else c doesn't.

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

1 participant