https://kotlinlang.org logo
#stdlib
Title
# stdlib
h

holgerbrandl

09/29/2017, 8:20 AM
Indeed @gaetan. Does kotlin-
log
at least provide
e
as default for the base? Because if so users could keep using
log
as natural logarithm. LIke in python https://docs.python.org/2/library/math.html#math.log or R http://astrostatistics.psu.edu/su07/R/html/base/html/Log.html
g

gildor

09/29/2017, 8:21 AM
localhost? 😀
h

holgerbrandl

09/29/2017, 8:22 AM
ups sorry, fixed!
g

gaetan

09/29/2017, 8:28 AM
I think there is a performance point.
ln
,
log10
and
log2
implementations directly delegated calls to native implementations which is not the case for
log
. 99,9% of use should have the best performance.
g

gildor

09/29/2017, 8:29 AM
But what if implementation just check base and use intrinsics for standard bases?
g

gaetan

09/29/2017, 8:32 AM
Could be. After it should be clearly explained. I was porting some code using kotlin.js.Math and didn’t understand at first that kotlin.js.Math.log was replaced by kotlin.math.ln. And again,
ln
is not the convention on java and javascript.
e

elizarov

09/29/2017, 8:36 AM
This is an interesting idea. However, we are adding math function on the top level, which forces us to consider a different set of tradeoffs.
In particular, if we were to support one-arg
log(x)
function for a natural logarithm, then it is highly likely that it is going to conflict with logging functions in many real-life projects.
👍 2
A function called
log
that can only be invoked with two doubles is less prone to this kind of confusion.
h

holgerbrandl

09/29/2017, 8:38 AM
sure, logging how could we miss that. Thanks for pointing that out.
g

gaetan

09/29/2017, 8:43 AM
Ok, then the documentation of
log(x,x)
should be more explicit, indicating
ln
,
log10
,
log2
.
e

elizarov

09/29/2017, 8:59 AM
Agree