https://kotlinlang.org logo
Title
m

mg6maciej

03/15/2017, 12:11 PM
I may have created a few impure properties in the past, but it might be a good default recommendation not to do that.
e

elect

03/15/2017, 1:50 PM
in my glm port, I have
Float.rad
to convert deg->rad,
Float.sin
and
.cos
, etc.. do you consider it bad?
m

mg6maciej

03/15/2017, 1:51 PM
No, not at all. Why would you think so? These are pure functions.
However I don't like how the resulting client code would look like.
x.sin
not readable as simply
sin(x)
.
e

elect

03/15/2017, 2:22 PM
an example of those impure properties?
m

mg6maciej

03/15/2017, 3:28 PM
Impure functions are those with implicit dependencies, i.e. may not return the same value for given set or arguments.
now
is a good example, but anything non-purely functional really, like using
Random().newInt()
inside such functions.
m

minivac

03/17/2017, 10:38 AM
I still think
sin(x)
makes more sense for pure functions because thats the default mathematical syntax, you never see
x.sin
out there
👍 1
e

elect

03/22/2017, 3:01 PM
@minivac yeah, you are right, but I find it somehow attractive because it has no parenthesis and it kind of follow the logic flow of "taking x and calculate sin"