fuzion
fuzion copied to clipboard
Syntax of field declaration confusing?
When I was a little tired working on my FOSDEM'23 submission, I had problems understanding the following code (taken from a comment in Fuzion base library feature cache.fz:
fn () -> cache_key := () -> cache_key (sortedArrayOf [6,4,1,9])
I think the Fuzion grammar might be confusing here.
Are there any good possibilities to change the grammar to make this clearer, the options I see are using a keyword like var
var fn () -> cache_key := () -> cache_key (sortedArrayOf [6,4,1,9]) # *** currently not allowed ***
or requiring the type to have no spaces
fn ()->cache_key := () -> cache_key (sortedArrayOf [6,4,1,9])
or putting the type in (/):
fn (() -> cache_key) := () -> cache_key (sortedArrayOf [6,4,1,9]) # *** currently not allowed ***
or permitting type inference for lambdas without arguments
fn := () -> cache_key (sortedArrayOf [6,4,1,9]) # *** currently not allowed ***
or, in general, permitting explicit types in lambdas
add := (a,b i32) -> a+b # *** currently not allowed ***
I kind of prefer this variant here:
fn Function cache_key := () -> cache_key (sortedArrayOf [6,4,1,9])