Mercurial > abomination
changeset 1:a4cb0b71fc78
got this working again
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 16 Oct 2011 07:52:40 -0700 |
parents | 1c7ace5054ac |
children | c436f5c7ebb4 |
files | .hgignore org/no_parens.org |
diffstat | 2 files changed, 32 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/.hgignore Sun Oct 16 07:32:21 2011 -0700 1.2 +++ b/.hgignore Sun Oct 16 07:52:40 2011 -0700 1.3 @@ -1,3 +1,4 @@ 1.4 syntax: glob 1.5 src* 1.6 -html* 1.7 \ No newline at end of file 1.8 +html* 1.9 +classes*
2.1 --- a/org/no_parens.org Sun Oct 16 07:32:21 2011 -0700 2.2 +++ b/org/no_parens.org Sun Oct 16 07:52:40 2011 -0700 2.3 @@ -4,8 +4,9 @@ 2.4 #+MATHJAX: align:"left" mathml:t path:"../MathJax/MathJax.js" 2.5 #+STYLE: <link rel="stylesheet" type="text/css" href="../css/aurellem.css" /> 2.6 #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t 2.7 -#+SETUPFILE: ../templates/level-0.org 2.8 -#+INCLUDE: ../templates/level-0.org 2.9 +#+SETUPFILE: ../../aurellem/org/level-0.org 2.10 +#+INCLUDE: ../../aurellem/org/level-0.org 2.11 +#+BABEL: :mkdirp yes 2.12 2.13 [TABLE-OF-CONTENTS] 2.14 2.15 @@ -34,35 +35,38 @@ 2.16 [this] 2.17 (System/exit 0)) 2.18 2.19 + 2.20 (defvar quit (abomination.no-parens.Quit.) 2.21 "a sneaky way to support a `quit` command") 2.22 #+end_src 2.23 2.24 -When you type any variable at the REPL, the REPL attempts to print it as a nicely-formatted string by calling its =toString= 2.25 -method. Our trick is to define a class with a =toString= method 2.26 -that exits the REPL; this trick ensures that any variable of that class will close 2.27 +When you type any variable at the REPL, the REPL attempts to print it 2.28 +as a nicely-formatted string by calling its =toString= method. Our 2.29 +trick is to define a class with a =toString= method that exits the 2.30 +REPL; this trick ensures that any variable of that class will close 2.31 the REPL when the REPL attempts to print it. 2.32 2.33 -First, we use =gen-class= to make a new class named Quit; in that same line, we use 2.34 -=:prefix= to establish the convention that any function named 2.35 -=quit-[something]= will be adopted as the =[something]= method for the 2.36 -newly-defined Quit class. We use this convention to write our own 2.37 -=toString= method for Quit. 2.38 +First, we use =gen-class= to make a new class named Quit; in that same 2.39 +line, we use =:prefix= to establish the convention that any function 2.40 +named =quit-[something]= will be adopted as the =[something]= method 2.41 +for the newly-defined Quit class. We use this convention to write our 2.42 +own =toString= method for Quit. 2.43 2.44 -Next, we define a suitable =toString= method for the Quit class so that 2.45 -attempting to print an instance of the Quit class has the effect of 2.46 -closing the REPL. We do this by defining a function =quit-toString= 2.47 +Next, we define a suitable =toString= method for the Quit class so 2.48 +that attempting to print an instance of the Quit class has the effect 2.49 +of closing the REPL. We do this by defining a function =quit-toString= 2.50 which closes the REPL; by the convention established above, the Quit 2.51 -class automatically adopts =quit-toString= as its =toString= method. 2.52 +class automatically adopts =quit-toString= as its =toString= method. 2.53 2.54 Finally, we use =defvar= to create an instance of the Quit class; we 2.55 name this instance =quit=. Now when you type =quit= into the REPL, the 2.56 -REPL executes the =toString= method of the Quit class, exiting the REPL instead of returning a 2.57 -string. 2.58 +REPL executes the =toString= method of the Quit class, exiting the 2.59 +REPL instead of returning a string. 2.60 2.61 #+begin_src clojure :exports both 2.62 -(binding [*compile-path* "/home/r/aurellem/classes"] 2.63 +(binding [*compile-path* "/home/r/proj/abomination/classes"] 2.64 (compile 'abomination.no-parens)) 2.65 + 2.66 #+end_src 2.67 2.68 #+results: 2.69 @@ -87,16 +91,18 @@ 2.70 The same thing, accomplished in a much more elegant and clojureish 2.71 way. 2.72 2.73 -#+begin_src clojure :tangle no_parens.clj :results silent :exports none :noweb yes 2.74 -<<header>> 2.75 -<<toString>> 2.76 -<<lazy-seq>> 2.77 -<<delay>> 2.78 -#+end_src 2.79 - 2.80 # STUD CRUFT PIZZA 2.81 2.82 #+begin_quote 2.83 And death i think is no parenthesis 2.84 \mdash{}E. E. Cummings 2.85 #+end_quote 2.86 + 2.87 + 2.88 +* COMMENT code generation 2.89 +#+begin_src clojure :tangle ../src/abomination/no_parens.clj :results silent :exports none :noweb yes 2.90 +<<header>> 2.91 +<<toString>> 2.92 +<<lazy-seq>> 2.93 +<<delay>> 2.94 +#+end_src