atspkg icon indicating copy to clipboard operation
atspkg copied to clipboard

Support more liberal function application?

Open kindaro opened this issue 5 years ago • 0 comments

For instance:

#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"

val pi: double = 3.14159

fn circleArea (r: double): double = pi * (r * r)

fn ringArea (R: double, r: double) = circleArea R - circleArea r

val s = ringArea (5.0, 4.0)
val _ = print s

implement main0 () = ()

— Looks legit.

% patscc hello.dats && ./a.out
28.260000%
% atsfmt hello.dats
Error: 8:49
  Unexpected 'R', expected: 'Declaration'

— The compiler agrees, but atsfmt has an issue. Maybe add parentheses?

...
fn ringArea (R: double, r: double) = circleArea (R) - circleArea (r)
...

— But no:

% atsfmt hello.dats
Error: unexpected token '-' at 8:53

(What it actually dislikes is white space in function application.)

Either we should silently re-format function application or ignore the supposed issue, but surely not error out.

kindaro avatar Jan 15 '20 12:01 kindaro