Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why? It can be just a syntactic sugar for method(object).


I think the point is that it special-cases the first object, at least in the syntax. You _could_ write it that way, but since the method is chosen based on all the object types, it doesn't make much sense to do so.


One could have a language where object.method(args) does single dispatch on "defined in a class" methods while method(object, object,...) does multiple dispatch on generic methods.

That could get really confusing for the language's users, though, if there were name clashes between the two, and they would be there in any reasonably large program.

And of course, argument order already gives the first and last arguments special attention.

Another way to diminish that special-casing is going to the extreme other end: object.object.object.method(). Remove the now superfluous parentheses and replace the periods by spaces and you end up with Forth.


The point was that object.method() is sometimes more readable. For example I find web_socket_manager.reconnect_if_needed() more readable than reconnect_if_needed(web_socket_manager).


That's because you are used to thinking in terms of objects, whereas in Julia the focus is on data and operations on data (the two are often conflated but they aren't the same).


I think in both depending on the situation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: