Skip to content

Consider using indentation for line-continuation #478

Open
@buster-blue

Description

@buster-blue

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions