Mercurial > rlm
view src/rlm/dreams.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children |
line wrap: on
line source
1 (ns rlm.dreams2 "These are functions and ideas that I have generated in dreams or3 on the edge of sleep, hastily written down on scraps of paper in a4 semi-somniac haze..."5 {:author "Robert McIntyre"}6 )9 (defn not-implemented []10 (throw (Exception. "not-implemented")))12 (defn get-current-ns [] *ns*)15 (defmacro silence16 "no print statements can escape from this form!!"17 [& body]18 `(binding [*out* (java.io.StringWriter.)19 *err* (java.io.StringWriter.)20 ] ~@body))22 (defmacro megadef23 "Like def but defines the var in every namespace24 currently in existance. Sometimes usefull for weeding25 out namespace errors."26 {:author "Robert McIntyre"}27 [symbol form]28 `(do ~@(map (fn [n] `(intern ~n ~(list 'quote symbol) ~form)) (all-ns))))31 (defmacro megaundef32 "hurrrrrrrrrrrr!!!!!!!"33 {:author "Robert McIntyre the Great"}34 [sym]35 `(do ~@(map (fn [n] `(ns-unmap ~n ~(list 'quote sym))) (all-ns))))37 (defmacro defn-decorated38 "like defn-memo except it accepts an additional vector of39 decorator functions which will be applied to the base definition."40 {:author "Robert McIntyre"}41 [decorators fn-name & defn-stuff]42 (let [decorations43 (map (fn [d] (list 'alter-var-root (list 'var fn-name) d)) decorators)]44 `(do45 (defn ~fn-name ~@defn-stuff)46 ~@decorations47 (var ~fn-name))))