Open bristermitten opened 4 years ago
In my opinion, with parentheses looks better, and people are more familiar with the parentheses
In my opinion, with parentheses looks better, and people are more familiar with the parentheses
Perhaps. I think it's mainly personal preference.
On a similar note, what about this?
I think we should consider changing the function syntax significantly I've been doing some research into FP and pretty much every functional language has much more concise function declaration
let square x = x * x
in F# for example
meanwhile in elara it would be
let square = (Int x) => x * x
which obviously is pretty verbose
If hypothetically we were to borrow F#'s syntax, we'd have a more concise syntax, functions and variables would still be declared in the same way, and we wouldn't need the hacky let blah => blah
anymore
Thoughts?
I still think that with let square x = x * x
it would be better, more verbose languages are less attractive to new programmers, from what I see.
Yeah I agree. As much as the current syntax is arguably clearer, the verbosity is going to be counter productive (especially considering that FP is all about small, repeatable functions)
Perhaps we could use the let square x = x * x
for functions, and the current syntax for anonymous functions
How would the contract be defined for x in that example?
Well, in F# there's some pretty powerful type inference for parameters.
If Elara doesn't support that, we could do
let square Int x = x * x
perhaps
Eg
let add Int a, Int b = a + b
Or of course something like
let add a: Int, b: Int = a + b
But I think parameter type inference is definitely something we should consider
Or of course something like
let add a: Int, b: Int = a + b
But I think parameter type inference is definitely something we should consider
I liked this way
This isn't anything fancy, just proposing a small tweak to function syntax
Would become
And
Would become
Without parentheses
Just an idea, but it looks cleaner imo