Closed danilopedraza closed 2 months ago
I've been thinking of something: Not using whitespace to define blocks, but semicolons. For example:
let f(x) :=
let y := x + 1;
y*y
let printAndReturn(x) := println(x); x
The last expression within the succession of expression is the result. It will be easier to code and I won't have to worry about formatting and consistency problems, but it can lead to errors. For example:
let f(x) :=
let y := x + 1;
y*y;
let printAndReturn(x):= println(x); x
The only difference between this example and the first is the semicolon after y*y
. However, this example defines a single function, which returns the printAndReturn
function.
I did it the semicolon way.
That didn't work out at all. I will go with indentation.
I naively implemented the emition of Indent
and Dedent
tokens. I'll go with the syntax and evaluation now.
Previously, I implemented anonymous functions. Their syntax makes one capable of writing sequences of steps, which was previously impossible outside the first level. I don't think this is a good solution.
Right now, Symstatic for-loops are written like this:
The thing is that you can only put one expression into the loop, which is weird, considering the syntax. I think it is a good thing to add indented blocks, because the alternative is to put several expressions in a loop with an anonymous function called in place, like this:
and it is kinda ugly.