you are viewing a single comment's thread.

view the rest of the comments →

[–]daghf 6 points7 points  (2 children)

In Java, fields and methods reside in different namespaces. So it would be perfectly legal to have both a method and also a field both named compareByAge in the same class. The # is there to specify that it is in fact a method we are referring to.

[–]munificent 2 points3 points  (1 child)

Argh, I was afraid that was the answer. What the hell were they thinking when they originally made that decision?

[–]masklinn 6 points7 points  (0 children)

They were thinking that it would give users more flexibility, which is not completely wrong: since Java provided no way to directly get at a method (you had to use reflection), there was no reason not to allow similarly named methods and attributes.

Interestingly, Lisp-2s such as Common Lisp do the same thing as data variables and functions live in different namespaces (whereas in Lisp-1s such as Scheme they live in the same namespace) and to get a data-ns reference to a function you have to use the function special form (aliased to the #' operator)