On Java, it make more sense to write as what you wrote in paper:

r = Math.sqrt(a*a + b*b)

So is there any better way to write math expression other than the above, e.g: like Java?

CretinHoTue 15 Jun 2021

Oh, it's getting insane:

r := a.mult(a).plus(b.mult(b)).sqrt

SlimerDudeTue 15 Jun 2021

r := ((a*a) + (b*b)).sqrt - any better?

CretinHoTue 15 Jun 2021

SlimerDude: still backward to what I normally write in Java but if it's the only style to write it on Fantom then I think I have to live with it! BTW, adding more redundancy brackets just make things more difficult to read. I still think my original is better:

r := (a*a + b*b).sqrt

SlimerDudeTue 15 Jun 2021

adding more redundancy brackets just make things more difficult to read.

Ah - I never did learn operator precedence, so I have to do it the long way!

still backward to what I normally write in Java

Maybe, but that's static methods vs instance methods for you! I personally liked the way Fantom moved everything to instance methods, it makes them easier to find!

go4Wed 1 Sep 2021

Math function is extension method in fanx :

mixin Math {
extensiosn static Float cos(Float self) { ... }
extensiosn static Float sin(Float self) { ... }
}
class Main : Math {
Void main() {
f := 0.1
//Fantom compatible style
r := f.cos * f.sin
//mathematics familiar style
r := cos(f) * sin(f)
}
}

## CretinHo Tue 15 Jun 2021

Current now, I have to write like this:

r := (a*a + b*b).sqrt

On Java, it make more sense to write as what you wrote in paper:

r = Math.sqrt(a*a + b*b)

So is there any better way to write math expression other than the above, e.g: like Java?

## CretinHo Tue 15 Jun 2021

Oh, it's getting insane:

r := a.mult(a).plus(b.mult(b)).sqrt

## SlimerDude Tue 15 Jun 2021

`r := ((a*a) + (b*b)).sqrt`

- any better?## CretinHo Tue 15 Jun 2021

SlimerDude: still backward to what I normally write in Java but if it's the only style to write it on Fantom then I think I have to live with it! BTW, adding more redundancy brackets just make things more difficult to read. I still think my original is better:

r := (a*a + b*b).sqrt

## SlimerDude Tue 15 Jun 2021

Ah - I never did learn operator precedence, so I

haveto do it the long way!Maybe, but that's static methods vs instance methods for you! I personally liked the way Fantom moved everything to instance methods, it makes them easier to find!

## go4 Wed 1 Sep 2021

Math function is extension method in fanx :