3 ms·
so no Java Function to clojure Function automating mapping ? do people use macros to make it nicer ?
by agumonkey 7y ago
so no Java Function to clojure Function automating mapping ? do people use macros to make it nicer ?
- Uhuhreally 7y agoyou'd use Clojure not Java for an example like the above
- Scarbutt 7y agoI think the context is when doing interop.
- Uhuhreally 7y agoyes but I got the feeling the grandparent was confused so I tried to clarify that the only reason for the verbosity is interop - the Clojure code is much more concise than the Java - the interop code is like listening to a speech being translated between English and Spanish
- dancek 7y agoNot out of the box, probably because java.util.function.Function seems like an afterthought in a strictly object-oriented language while Clojure has first class functions. In practice you don't interop with Java very much, let alone functional Java (as Clojure itself is a much better fit). But if it was useful, it'd be easy to write helpers for converting functions back and forth.
- serpix 7y agofunctions. Macros are a super weapon and their use is reserved for very special cases. One reason is macros can't be composed as functions and also readability goes out the windows.