rlm@0: (ns rlm.dreams rlm@0: "These are functions and ideas that I have generated in dreams or rlm@0: on the edge of sleep, hastily written down on scraps of paper in a rlm@0: semi-somniac haze..." rlm@0: {:author "Robert McIntyre"} rlm@0: ) rlm@0: rlm@0: rlm@0: (defn not-implemented [] rlm@0: (throw (Exception. "not-implemented"))) rlm@0: rlm@0: (defn get-current-ns [] *ns*) rlm@0: rlm@0: rlm@0: (defmacro silence rlm@0: "no print statements can escape from this form!!" rlm@0: [& body] rlm@0: `(binding [*out* (java.io.StringWriter.) rlm@0: *err* (java.io.StringWriter.) rlm@0: ] ~@body)) rlm@0: rlm@0: (defmacro megadef rlm@0: "Like def but defines the var in every namespace rlm@0: currently in existance. Sometimes usefull for weeding rlm@0: out namespace errors." rlm@0: {:author "Robert McIntyre"} rlm@0: [symbol form] rlm@0: `(do ~@(map (fn [n] `(intern ~n ~(list 'quote symbol) ~form)) (all-ns)))) rlm@0: rlm@0: rlm@0: (defmacro megaundef rlm@0: "hurrrrrrrrrrrr!!!!!!!" rlm@0: {:author "Robert McIntyre the Great"} rlm@0: [sym] rlm@0: `(do ~@(map (fn [n] `(ns-unmap ~n ~(list 'quote sym))) (all-ns)))) rlm@0: rlm@0: (defmacro defn-decorated rlm@0: "like defn-memo except it accepts an additional vector of rlm@0: decorator functions which will be applied to the base definition." rlm@0: {:author "Robert McIntyre"} rlm@0: [decorators fn-name & defn-stuff] rlm@0: (let [decorations rlm@0: (map (fn [d] (list 'alter-var-root (list 'var fn-name) d)) decorators)] rlm@0: `(do rlm@0: (defn ~fn-name ~@defn-stuff) rlm@0: ~@decorations rlm@0: (var ~fn-name)))) rlm@0: rlm@0: rlm@0: