Writing complex systems will require you to use strong sides of a complete infrastructure and have interoperability on all levels, within JVM and across the applications running on different platforms. kthxbai Saturday, June 9, 12
is not panacea, and should be used with care and diligence. Although Clojure will teach you to compose things rather than build inheritance chains, avoid side effects and utilize maximum of lang core. It’s not Scala, so you can’t write your Java in Clojure. Saturday, June 9, 12
datatypes only expose their methods in protocols and interfaces - immutability is a preferred default (didn’t we want to make it happen in our Java code anyways?) - tying polymorphism to inheritance is bad (extending types with protocols help you to avoid it) - prefer composition over inheritance (but that’s more of a clojuric thing) Saturday, June 9, 12
(. mo connectTimeout) connect-timeout) (set! (. mo socketTimeout) socket-timeout) (set! (. mo socketKeepAlive) socket-keep-alive)) Saturday, June 9, 12
the methods and functions with the value of x supplied at the front of the given arguments. The forms are evaluated in order. Returns x. Saturday, June 9, 12
the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc. Saturday, June 9, 12
the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc. (basically, same thing as -> just backwards) Saturday, June 9, 12
proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provided it defaults to Object. Saturday, June 9, 12
of that type. The use case is where you need a one-off implementation of one or more protocols or interfaces and would like to take advantage of the local context. In this respect it is use case similar to proxy, or anonymous inner classes in Java. Saturday, June 9, 12
enough (no need in named type) - preferred, unless semantics force you to use proxy - only protocols and interfaces supported, no concrete superclass - method bodies real fns of resulting class, not external fns - invocation is direct, without map lookup - no support for dynamic method swapping - better performance - returns instance of implementation Saturday, June 9, 12
name, in a package with the same name as the current namespace, the given fields, and, optionally, methods for protocols and/or interfaces. Saturday, June 9, 12
(extend-protocol cache/CacheProtocol BasicWelleCache (lookup [c k] (:value (kv/fetch-one (.bucket c) k))) (has? [c k] (not (empty? (kv/fetch (.bucket c) k :head-only true)))) (hit [this k] this) (miss [c k v] (kv/store (.bucket c) k v :content-type (.content-type c) :w (.w c)) c) (evict [c k] (kv/delete (.bucket c) k :w (.w c)) c) (seed [c m] (doseq [[k v] m] (kv/store (.bucket c) k v :content-type (.content-type c) :w (.w c))) c)) * yes, this is polymorphism, as you can declare another record and extend CacheProtocol with it. Here we go, polymorphism FTW! Saturday, June 9, 12
name, in a package with the same name as the current namespace, the given fields, and, optionally, methods for protocols and/or interfaces. Saturday, June 9, 12
to be AOT compiled - generates named class (real thing) - fields can have type hints - can implement one or more protocols/interfaces - supports mutable fields - no functionality specified by user, only constructor Saturday, June 9, 12
the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. Saturday, June 9, 12