OJacot-Descombes / dsharp

Open-source .NET compiler for D# (d-sharp), a "C#" with simplified syntax.
MIT License
0 stars 0 forks source link

Line-orientation and continuation lines and blocks #3

Open OJacot-Descombes opened 8 years ago

OJacot-Descombes commented 8 years ago

The language is line-oriented. Continuation lines are introduced with a back-tick ( ` ) and their indentation does not matter. Nested blocks have an indentation increased by 4 spaces.

Advantages: Line-orientation removes the need for semicolons and parentheses in many situations. Indentation sensitiveness allows to eliminate curly braces and block-end symbols. A line continuation character at the beginning of the line has a better visibility compared to a continuation character at a line end.

Line orientation enforces a unique style, unlike in C# where you can have a unique statement in an if-statement on the same line, indented on the next line, enclosed in braces, on the same line, first brace on the same line, braces indented, not indented etc., etc., etc...

Example:

if a < 100 && b < 100 &&
`  c < 100 && d < 100
    WriteLine("They are all less than 100")
else
    WriteLine("Some guy is too big")

Example of alignment. A back-tick indicates a continuation line:

while i < a.Length &&
`     a[i] == null
    i++

I expect that the IDE will provide visual hints like lines or indentation based background coloring:

background_coliring

iamcarbon commented 7 years ago

Most modern C like languages (i.e. SWIFT, RUST, GOLANG) retain braces have made retained braces but loosened up rules for what needs to be parenthesized and terminated with a semicolon.

I believe most of the language simplifications can be made around strongly type inference, reducing the need for parenthesis and semicolons, breve type declarations (i.e. records), and stronger pattern matching.

For thought.