Skip to content

Instantly share code, notes, and snippets.

@malisper
Last active August 29, 2015 14:22
Show Gist options
  • Save malisper/fe2cf8158714c196ec03 to your computer and use it in GitHub Desktop.
Save malisper/fe2cf8158714c196ec03 to your computer and use it in GitHub Desktop.
Trace of functions in CL-WHO
(macroexpand-1 '(with-html-output (*standard-output*)
(:p :align "right" "Here is some text with a part of it "
(:b "bolded."))))
;; The function trace
0: (TREE-TO-TEMPLATE
((:P :ALIGN "right" "Here is some text with a part of it "
(:B "bolded."))))
1: (PROCESS-TAG
(:P :ALIGN "right" "Here is some text with a part of it "
(:B "bolded."))
#<CLOSURE SB-IMPL::ENCAPSULATION {100712692B}>)
2: (CONVERT-TAG-TO-STRING-LIST :P ((:ALIGN . "right"))
("Here is some text with a part of it "
(:B "bolded."))
#<CLOSURE SB-IMPL::ENCAPSULATION
{100712692B}>)
3: (TREE-TO-TEMPLATE
("Here is some text with a part of it " (:B "bolded.")))
4: (PROCESS-TAG (:B "bolded.")
#<CLOSURE SB-IMPL::ENCAPSULATION {100712692B}>)
5: (CONVERT-TAG-TO-STRING-LIST :B NIL ("bolded.")
#<CLOSURE SB-IMPL::ENCAPSULATION
{100712692B}>)
6: (TREE-TO-TEMPLATE ("bolded."))
6: TREE-TO-TEMPLATE returned ("bolded.")
5: CONVERT-TAG-TO-STRING-LIST returned
("<" "b" ">" "bolded." "</" "b" ">")
4: PROCESS-TAG returned ("<" "b" ">" "bolded." "</" "b" ">")
3: TREE-TO-TEMPLATE returned
("Here is some text with a part of it " "<" "b" ">" "bolded." "</"
"b" ">")
2: CONVERT-TAG-TO-STRING-LIST returned
("<" "p" " " "align" "='" "right" "'" ">"
"Here is some text with a part of it " "<" "b" ">" "bolded." "</"
"b" ">" "</" "p" ">")
1: PROCESS-TAG returned
("<" "p" " " "align" "='" "right" "'" ">"
"Here is some text with a part of it " "<" "b" ">" "bolded." "</" "b"
">" "</" "p" ">")
0: TREE-TO-TEMPLATE returned
("<" "p" " " "align" "='" "right" "'" ">"
"Here is some text with a part of it " "<" "b" ">" "bolded." "</" "b"
">" "</" "p" ">")
;; Everything after this is the expanded code returned from macroexpand-1
(LET ((*STANDARD-OUTPUT* *STANDARD-OUTPUT*))
(CHECK-TYPE *STANDARD-OUTPUT* STREAM)
(MACROLET ((HTM (&BODY BODY)
`(WITH-HTML-OUTPUT (,'*STANDARD-OUTPUT* NIL :PROLOGUE NIL
:INDENT ,NIL)
,@BODY))
(FMT (&REST ARGS)
`(FORMAT ,'*STANDARD-OUTPUT* ,@ARGS))
(ESC (THING)
(WITH-UNIQUE-NAMES (RESULT)
`(LET ((,RESULT ,THING))
(WHEN ,RESULT
(WRITE-STRING (ESCAPE-STRING ,RESULT)
,'*STANDARD-OUTPUT*)))))
(STR (THING)
(WITH-UNIQUE-NAMES (RESULT)
`(LET ((,RESULT ,THING))
(WHEN ,RESULT (PRINC ,RESULT ,'*STANDARD-OUTPUT*))))))
(WRITE-STRING
"<p align='right'>Here is some text with a part of it <b>bolded.</b></p>"
*STANDARD-OUTPUT*)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment