News for hackers. Stuff that matters.
Re:Interesting features from various modern programming lang... by tom_mellior on Friday November 10, 2017 @10:05AM (#15670288)
> those are not functions with arguments, they're all 0-arity method calls

In other words, they are 1-argument function calls. The "this"/"self" parameter is implicit in many languages, but otherwise it's not different from a normal function parameter. In the "method chaining" version of the example, each method call returns a (reference to) a temporary object which is passed as the next method call's "this" parameter.

Re:Interesting features from various modern programming lang... by bunderbunder on Friday November 10, 2017 @10:28AM (#15670458)
In most languages, that's an implementation detail that is hidden by the compiler, and not a part of the semantics of the language itself.

More specifically, if the language won't allow me to do both:

  foo.method(x)
and

  method(foo, x)
and have them behave the same way, then I submit that, regardless of what's going on behind the curtain, a n-arity method is not really the same thing as a (n+1)-arity function in that language.
Re:Interesting features from various modern programming lang... by kd5bjo on Friday November 10, 2017 @12:38PM (#15671479)
Python is pretty close to this. Assuming that foo is an instance of class Bar,

foo.method(x)

Is equivalent[1] to

Bar.method(foo, x)

[1] in the absence of monkey patching on foo