When should one prefer Kotlin extension functions?
<p>In Kotlin, a function with at least one argument can be defined either as a regular non-member function or as an <a href="https://kotlinlang.org/docs/reference/extensions.html#extension-functions" rel="noreferrer">extension function</a> with one argument being a receiver.</p>

<p>As to the scoping, there seems to be no difference: both can be declared inside or outside classes and other functions, and both can or cannot have visibility modifiers equally.</p>

<p>Language reference seems not to recommend using regular functions or extension functions for different situations.</p>

<p>So, my question is: <strong>when do extension functions give advantage over regular non-member ones?</strong> And when regular ones over extensions?</p>

<p><code>foo.bar(baz, baq)</code> vs <code>bar(foo, baz, baq)</code>.</p>

<p>Is it just a hint of a function semantics (receiver is definitely in focus) or are there cases when using extensions functions makes code much cleaner or opens up opportunities?</p>