In Jarc, java method calls look like regular function calls: (getTime (new java.lang.Date))
Global functions don't override this. The above works even if
there's a getTime function defined earlier: (def getTime (x) (+ "" (seconds) ": " x))
This has the advantage that global functions don't need
to change when new objects are introduced.If you want the global function you have to use apply: (apply getTime (list (new java.util.Date))) => "1272754463: Sat May 01 ..."
In Jarc, you apply symbols to call Java methods: (apply 'getTime (list (new java.util.Date))) => 1272754029623
But should lexically bound functions override this? (def foo (getTime x)
(... (getTime x) ...)
If lexically bound functions take precedence, then the compiler
can generate faster code for functions that take a fn as an argument.So the important question seems to be: Is the coder likely to make a mistake and reuse a Java method
name as a fn argument name without realizing it? Probably not. Let's say I'm writing (def xyz (foo o)
(... (foo o) ...)) Then I'm pretty sure I'd always want the local foo
to be applied. I can't imagine a case where I'd want
some Java method named foo to be called instead. Thoughts? |