Skip to main content

reify

macrov1.7

cljs.core/reify

Available in:BBCLJCLJS
(reify [& impls])
reify creates an object implementing a protocol. reify is a macro with the following structure: (reify options* specs*) Currently there are no options. Each spec consists of the protocol name followed by zero or more method bodies: protocol (methodName [args+] body)* Methods should be supplied for all methods of the desired protocol(s). You can also define overrides for Object methods. Note that the first parameter must be supplied to correspond to the target object ('this' in JavaScript parlance). Note also that recur calls to the method head should *not* pass the target object, it will be supplied automatically and can not be substituted. recur works to method heads The method bodies of reify are lexical closures, and can refer to the surrounding local scope: (str (let [f "foo"] (reify Object (toString [this] f)))) == "foo" (seq (let [f "foo"] (reify ISeqable (-seq [this] (seq f))))) == ("f" "o" "o")) reify always implements IMeta and IWithMeta and transfers meta data of the form to the created object. (meta ^{:k :v} (reify Object (toString [this] "foo"))) == {:k :v}

No examples yet. Be the first to add one!