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

Consider using indentation for line-continuation #478

Open
buster-blue opened this issue Jan 8, 2024 · 1 comment
Open

Consider using indentation for line-continuation #478

buster-blue opened this issue Jan 8, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@buster-blue
Copy link
Contributor

Currently, it seems that the only way to continue a statement over multiple lines is to use the backslash character, like Python does. Another programming language that uses significant indentation is Ante, and it has an interesting alternative to backslashes. Instead, you can continue a line across multiple lines by indenting the following lines. So for example, in Erg, this expression:

1..100 \
|>.iter() \
|>.filter i -> i % 2 == 0 \
|>.collect Array

could instead by written as:

1..100
    |>.iter()
    |>.filter i -> i % 2 == 0
    |>.collect Array

Which I think looks much better, and it's also easier to see at a glance where the line continuations are happening, because they're visually grouped.

For what it's worth, Nim also appears to allow you to continue lines this way.

func increment(num: Natural): Natural = num + 1
let testNum: Natural = 0
let testNum2 = testNum
  .increment
  .increment

assert testNum2 == 2
@buster-blue buster-blue added the enhancement New feature or request label Jan 8, 2024
@buster-blue buster-blue changed the title Consider indentation for line-continuation Consider using indentation for line-continuation Jan 8, 2024
@mtshiba
Copy link
Member

mtshiba commented Jan 21, 2024

This relates to #393.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants