java - how to translate the double colon operator to clojure? -


i discovered new syntax java 8 reading through source framework i'm attempting wrangle:

 runtime.getruntime().addshutdownhook(new thread(sirius::stop)); 

in clojure, can translate as:

(.addshutdownhook (runtime/getruntime) (thread. ????)) 

but i'm not sure put ???


ifn extends runnable, can do

#(sirius/stop) 

it worth noting that

  • you have make lambda. clojure won't let refer sirius/stop
  • java 8 functional interfaces under hood work making anonymous implementations of interfaces 1 method. so

    new thread(sirius::stop)

is syntactic sugar for

new thread(new runnable {     public void run() {         sirius.stop();     } }) 

if interface in question isn't runnable/callable, you'll have use reify macro.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -