From 2382283b2f95a82f0ed1ff1399ccde8133677b8b Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Wed, 24 Aug 2016 17:21:18 +0200 Subject: [PATCH 1/4] proposal for line continuations --- text/00000-line_continuations.md | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 text/00000-line_continuations.md diff --git a/text/00000-line_continuations.md b/text/00000-line_continuations.md new file mode 100644 index 0000000..6227214 --- /dev/null +++ b/text/00000-line_continuations.md @@ -0,0 +1,67 @@ +# Line Continuations + +- Created: 2016-08-24 by @arBmind + +## Summary +[Summary]: #summary + +I propose a way to handle line continuations and expression separation without semicolons. + +## Motivation +[Motivation]: #motivation + +In order to get a very fluent language we should not require semicolons. +Semicolons are one of the hardest things to learn in a programming language. + +## Detailed design +[Detailed design]: #detailed-design + +Removing the requirement to place semicolons between all statements reduces a huge error potential for programmers. + +It can be achieved through differenet strategies: +* Automatically place semicolons with rules like Javascript or Ruby does it. + - This leads to issues if developers do not remember these rules. +* Use indentation to mark line continuations like Python does it. + - This rule is very simple and very visual. + +We also want to allow multiple lines of visually nested line continuations. + +This should be valid. +``` +line1 + continue1 + continue1a + continue2 +``` +All lines are parsed as if it was one line, with whitespaces where the line breaks are. + +It should be illegal to jump above it first continuation line. +``` +line1 + continue1 + more # <= error +``` +Visually this pattern is reserved for blocks. +The error should propose to start a block or indent the line correctly. +Internally the `more` starts a block and is added to the line continuation. +Later errors in parsing either of these are ignored. + +## Drawbacks +[Drawbacks]: #drawbacks + +### This introduces semantics to indentation + +As every developer should indent these statements any way, so they become readable, I do not the a large issue here. + +## Alternatives +[Alternatives]: #alternatives + +### Add a continuation operator like shells + +This would basically be the inverse rule to a semicolon. +It is also visually not pleasing and kind of hard to maintain. + +## Unresolved questions +[Unresolved questions]: #unresolved-questions + +None so far. From 09d8c2be0ed46ee22609ce2428d05777ba14f497 Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Wed, 24 Aug 2016 17:30:03 +0200 Subject: [PATCH 2/4] assigned pr # --- text/{00000-line_continuations.md => 00009-line_continuations.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename text/{00000-line_continuations.md => 00009-line_continuations.md} (100%) diff --git a/text/00000-line_continuations.md b/text/00009-line_continuations.md similarity index 100% rename from text/00000-line_continuations.md rename to text/00009-line_continuations.md From a8be8bdc3fceb3851b77244fc8da11063cbb5e0e Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Sun, 28 May 2017 19:35:44 +0200 Subject: [PATCH 3/4] renamed file for new PR# --- text/{00009-line_continuations.md => 00018-line_continuations.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename text/{00009-line_continuations.md => 00018-line_continuations.md} (100%) diff --git a/text/00009-line_continuations.md b/text/00018-line_continuations.md similarity index 100% rename from text/00009-line_continuations.md rename to text/00018-line_continuations.md From ebdeb93d5ce467a9dbd8aed67bd33d9b859bbd75 Mon Sep 17 00:00:00 2001 From: Andreas Reischuck Date: Sun, 3 Jun 2018 23:31:50 +0200 Subject: [PATCH 4/4] cleaned up text and strucleaned up text and structure --- text/00018-line_continuations.md | 67 ++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/text/00018-line_continuations.md b/text/00018-line_continuations.md index 6227214..b9f09bc 100644 --- a/text/00018-line_continuations.md +++ b/text/00018-line_continuations.md @@ -1,11 +1,12 @@ # Line Continuations -- Created: 2016-08-24 by @arBmind +- Created: 2016-08-24 by arBmind +- Updated: 2018-06-03 by arBmind ## Summary [Summary]: #summary -I propose a way to handle line continuations and expression separation without semicolons. +This RFC proposes a way to handle epxression separation and continuations without the use of separator signs like semicolons. ## Motivation [Motivation]: #motivation @@ -13,18 +14,38 @@ I propose a way to handle line continuations and expression separation without s In order to get a very fluent language we should not require semicolons. Semicolons are one of the hardest things to learn in a programming language. +Removing the requirement to place semicolons between all statements reduces a huge error potential for programmers. + ## Detailed design [Detailed design]: #detailed-design -Removing the requirement to place semicolons between all statements reduces a huge error potential for programmers. +This paper proposes the use of indentation for line continuations. +This is a visual approach that is also used by Python. + +Two lines with the same indentation are treated as two separate expressions. +``` +line1 +line2 +``` + +If the second line is indented more, the expression started in the first line is continued in the second line. +``` +line1 + line2 +``` + +### Tabs or Spaces + +Unlike Python we do not want to impose our own preference to every developer. + +Both styles are allowed. But mixing them in one file is an error. -It can be achieved through differenet strategies: -* Automatically place semicolons with rules like Javascript or Ruby does it. - - This leads to issues if developers do not remember these rules. -* Use indentation to mark line continuations like Python does it. - - This rule is very simple and very visual. +* Once the compiler has seen tabs for indentation, the use of spaces for indentations is an error. +* Vice versa, once Spaces were used for indentations, the use of tabs for indentations is an error. -We also want to allow multiple lines of visually nested line continuations. +### Nested Line Continuation + +Nesting continuations deeper should be allowed. This will help to group arguments in complex calls. This should be valid. ``` @@ -33,7 +54,9 @@ line1 continue1a continue2 ``` -All lines are parsed as if it was one line, with whitespaces where the line breaks are. +All lines above are parsed as if it was one line, with whitespaces where the line breaks are. + +### Error: Backed off continuations It should be illegal to jump above it first continuation line. ``` @@ -42,21 +65,41 @@ line1 more # <= error ``` Visually this pattern is reserved for blocks. + The error should propose to start a block or indent the line correctly. Internally the `more` starts a block and is added to the line continuation. Later errors in parsing either of these are ignored. + ## Drawbacks [Drawbacks]: #drawbacks ### This introduces semantics to indentation -As every developer should indent these statements any way, so they become readable, I do not the a large issue here. +As every developer should indent these statements any way, so they become readable. I do not the a large issue here. + +### IDE support + +IDEs have a hard time to help you do the right thing. +They basically do not know if a line should be continued or seperated. + +A good IDE might use the same rules as automatic semicolon insertions and try to help the programmer to get it right. The big benefit here is that the solution is visible and errors can easily be fixed. + ## Alternatives [Alternatives]: #alternatives -### Add a continuation operator like shells +### Expression delimter + +As stated in the motivation, we want to avoid the noise of adding semicolons or any other delimiter. + +### Automatically insert delimiters + +We could define rules like Javascript and Ruby that insert semicolons automatically. + +Even though this works fine most of the time. When it fails to do the right thing nobody seems to remember all the rules and edge cases. + +### Continuation markers This would basically be the inverse rule to a semicolon. It is also visually not pleasing and kind of hard to maintain.