futhark
futhark copied to clipboard
Allowing omission of 'let' before 'loop', 'if', and 'match'
For a long time we've supported not having to put in
when chaining let
:
let foo = ...
let bar = ...
let baz = ...
in ...
Sometimes the expression following in
is a loop
, if
, or match
. In those cases, we could also make the in
itself optional. Then we could write things like
def build_table (rng: E.rng) =
let xs = replicate k (int.i32 0)
loop (rng,xs) for i < K.k do
let (rng,x) = E.rand rng
in (rng, xs with [i] = x)
or
let examinationPoint = lowerLimit + ( (upperLimit - lowerLimit) / 2 )
if A[examinationPoint] > quarry
then (lowerLimit, examinationPoint)
else (examinationPoint, upperLimit)
It's a pretty simple change to the grammar and completely unambiguous. But is it something we want?
Hm, I'm not sure I like the aesthetics of this. Of course, you'll save writing a keyword here and there, but I don't feel like there's any real benefit to it.
I think the main advantage (if any) is less indentation.
Do we have many programs that are so deeply indented that this will cause a significant difference?
No, but it sometimes causes a small difference.
I personally would even think it's more confusing as a programmer learning Futhark. I'd rather see it being consistent and having the in
everywhere. But that's just me. I'm not a language theorist. I just use Futhark :p
Alright, let's not do this.