Search code examples
line-breakslanguage-design

End of statement linebreaks


I'm currently experimenting with a programming language. I defined the basic syntax and wrote a pretty simple parser some months ago. Today I wanted to continue the project, but after a short time there was something about the syntax that bothered me.

The end of statement

When I started the Project I thought using linebreaks as end of statement would be nice. Just like that:

public fnc addPerson: Person personInstance
{
    [this.collection.add: personInstance]
    return this
}

Now today I think it would look and fell much better using semicolons which also would allow putting the entire thing in one line.

public fnc addPerson: Person personInstance
{
    [this.collection.add: personInstance]; return this;
}

I really wonder what are from an objective ( not technical) perspective the pros and cons of those?

I mean using linebreaks will force the the developer (at least a bit) to write clean code. But it makes the thing pretty inflexible.

  • In what kind of problems you will probably run into (as a user of the language) using the linebreak end of statement?
  • What language feature limitations will I have to accept using linebreaks or semicolons?

Solution

  • We had all this before, with assembler, RPG, Cobol, and various other tabular languages where line terminators were significant. Harder to write compilers for. We don't need to go back there.

    When this was first done back then, everybody realized the need for a statement continuation indicator, so you could break statements over multiple lines. Now that Scala et al. have reintroduced this they've forgotten that part of it, so it becomes impossible to present long statements in an acceptable format.

    Not a good idea. Whitespace is whitespace, not syntax.