Refactoring to Macros with Clojure

of 51/51
Refactoring to Macros with Clojure Dimitry Solovyov @dimituri
  • date post

    10-May-2015
  • Category

    Technology

  • view

    2.876
  • download

    0

Embed Size (px)

Transcript of Refactoring to Macros with Clojure

2. Lets talk aboutFUNCTIONAL PROGRAMMING 3. liftIO $ atomicModifyIORef sc $ n -> (n + 1, ())d >: onInnerliftIO $ ds `addDisposable` d 4. >>: 5. Lets talk aboutLISP 6. LISP in 3 minutesvia @bodiltv 7. object.method(a, b); 8. object.method( a b) 9. ClojureIts a LispCompiledDynamic typesType hintsMacros 10. ClojureIts a LispCompiledDynamic typesType hintsMacrosOptional static typesOptional Prolog 11. http://clojure.org/java_interop 12. HttpServer server = HttpServer.create(address, 0);server.createContext(path, handler);server.setExecutor(null);server.start(); 13. HttpServer server = HttpServer.create(address, 0);server.createContext(path, handler);server.setExecutor(null);server.start();(doto (HttpServer/create address 0) (.createContext path handler) (.setExecutor nil) (.start)) 14. macro |makr|noun ( pl. macros )1 (also macro instruction) Computing a single instructionthat expands automatically into a set of instructionsto perform a particular task. 15. (let* [G__360 (HttpServer/create address 0)] (.createContext G__360 path handler) (.setExecutor G__360 nil) (.start G__360) G__360)(doto (HttpServer/create address 0) (.createContext path handler) (.setExecutor nil) (.start)) 16. 17. .println(Encoding.encodeBase64(Encoding.decodeUrl(Encoding.decodeBas 18. String url = Encoding.decodeBase64(b);String decodedUrl = Encoding.decodeUrl(url);String encodedUrl = Encoding.encodeBase64(decodedUrl);System.out.println(encodedUrl); 19. String url = Encoding.decodeBase64(b);String decodedUrl = Encoding.decodeUrl(url);String encodedUrl = Encoding.encodeBase64(decodedUrl);System.out.println(encodedUrl);(-> b Encoding/decodeBase64 Encoding/decodeUrl Encoding/encodeBase64 println) 20. ->(-> stuff (foo ,,, a) (bar ,,, b c d) (baz ,,, e f)) 21. ->>->(-> stuff (foo ,,, a) (bar ,,, b c d) (baz ,,, e f))(->> stuff (foo a ,,,) (bar b c d ,,,) (baz e f ,,,)) 22. -->>->(-> stuff (foo ,,, a) (bar ,,, b c d) (baz ,,, e f))(->> stuff (foo a ,,,) (bar b c d ,,,) (baz e f ,,,))(- stuff (foo a ) (bar b c d) (baz e f)) 23. Swiss Arrows-> -? -!> -!>>-!