# HG changeset patch # User Robert McIntyre # Date 1318776760 25200 # Node ID a4cb0b71fc78fec0ca85287148ce66c3432d883b # Parent 1c7ace5054ac5254a16099f34beee8b0d75f5fd7 got this working again diff -r 1c7ace5054ac -r a4cb0b71fc78 .hgignore --- a/.hgignore Sun Oct 16 07:32:21 2011 -0700 +++ b/.hgignore Sun Oct 16 07:52:40 2011 -0700 @@ -1,3 +1,4 @@ syntax: glob src* -html* \ No newline at end of file +html* +classes* diff -r 1c7ace5054ac -r a4cb0b71fc78 org/no_parens.org --- a/org/no_parens.org Sun Oct 16 07:32:21 2011 -0700 +++ b/org/no_parens.org Sun Oct 16 07:52:40 2011 -0700 @@ -4,8 +4,9 @@ #+MATHJAX: align:"left" mathml:t path:"../MathJax/MathJax.js" #+STYLE: #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t -#+SETUPFILE: ../templates/level-0.org -#+INCLUDE: ../templates/level-0.org +#+SETUPFILE: ../../aurellem/org/level-0.org +#+INCLUDE: ../../aurellem/org/level-0.org +#+BABEL: :mkdirp yes [TABLE-OF-CONTENTS] @@ -34,35 +35,38 @@ [this] (System/exit 0)) + (defvar quit (abomination.no-parens.Quit.) "a sneaky way to support a `quit` command") #+end_src -When you type any variable at the REPL, the REPL attempts to print it as a nicely-formatted string by calling its =toString= -method. Our trick is to define a class with a =toString= method -that exits the REPL; this trick ensures that any variable of that class will close +When you type any variable at the REPL, the REPL attempts to print it +as a nicely-formatted string by calling its =toString= method. Our +trick is to define a class with a =toString= method that exits the +REPL; this trick ensures that any variable of that class will close the REPL when the REPL attempts to print it. -First, we use =gen-class= to make a new class named Quit; in that same line, we use -=:prefix= to establish the convention that any function named -=quit-[something]= will be adopted as the =[something]= method for the -newly-defined Quit class. We use this convention to write our own -=toString= method for Quit. +First, we use =gen-class= to make a new class named Quit; in that same +line, we use =:prefix= to establish the convention that any function +named =quit-[something]= will be adopted as the =[something]= method +for the newly-defined Quit class. We use this convention to write our +own =toString= method for Quit. -Next, we define a suitable =toString= method for the Quit class so that -attempting to print an instance of the Quit class has the effect of -closing the REPL. We do this by defining a function =quit-toString= +Next, we define a suitable =toString= method for the Quit class so +that attempting to print an instance of the Quit class has the effect +of closing the REPL. We do this by defining a function =quit-toString= which closes the REPL; by the convention established above, the Quit -class automatically adopts =quit-toString= as its =toString= method. +class automatically adopts =quit-toString= as its =toString= method. Finally, we use =defvar= to create an instance of the Quit class; we name this instance =quit=. Now when you type =quit= into the REPL, the -REPL executes the =toString= method of the Quit class, exiting the REPL instead of returning a -string. +REPL executes the =toString= method of the Quit class, exiting the +REPL instead of returning a string. #+begin_src clojure :exports both -(binding [*compile-path* "/home/r/aurellem/classes"] +(binding [*compile-path* "/home/r/proj/abomination/classes"] (compile 'abomination.no-parens)) + #+end_src #+results: @@ -87,16 +91,18 @@ The same thing, accomplished in a much more elegant and clojureish way. -#+begin_src clojure :tangle no_parens.clj :results silent :exports none :noweb yes -<
> -<> -<> -<> -#+end_src - # STUD CRUFT PIZZA #+begin_quote And death i think is no parenthesis \mdash{}E. E. Cummings #+end_quote + + +* COMMENT code generation +#+begin_src clojure :tangle ../src/abomination/no_parens.clj :results silent :exports none :noweb yes +<
> +<> +<> +<> +#+end_src