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

The criticism does not apply to Scala because paren-less method calls are the norm, and because () was never intended to distinguish between field access and a method call. To assume x.y is a cheap operation in Scala would be to apply an assumption from other languages that is not valid in Scala. (Using parens for a zero-arg method in Scala communicates something else: by convention, x.y() is used if y has side effects, and x.y is used otherwise. I don't know how widely that convention is observed, though.)

Python is different because the style guide explicitly discourages [1] computationally expensive accessor methods (as well as accessor methods with side effects) specifically so that programmers can treat accessor methods the same way they would treat a data field. Assuming that x.y is a field access in Python is not supposed to lead to problems, and if it does, it's the fault of the class implementer and not the user.

[1] http://www.python.org/dev/peps/pep-0008/#designing-for-inher...



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

Search: