Marcin Tustin wrote:
> On Fri, Sep 17, 2004 at 06:30:24PM +0200, Giannandrea Castaldi wrote:
>
>>Hi all,
>>I'm trying to call a lambda returned by a function with funcall but I've
>>the following error:
>
>
>>and this is where I call it:
>>
>>(defun apply-line-processors (lines line-processors)
>> (let (result)
>> (dolist (line lines (nreverse result))
>> (push (dolist (line-processor line-processors line)
>> (setf line (funcall line-processor line))) result))))
>>
>>I doesn't understand why the error says 'macro function' given that I'm
>>trying to executing a lambda.
>
>
> line-processor appears not to have been defined in the code given.
>
>
>
Here is the code that doesn't work: a test written with fiveAM where the
result of list-insertion is passed to apply-line-processors:
(test signed-list-insertion
(let ((*wikiroot* "/home/gcast/workspace/SpikeCl/wiki/data-for-tests/"))
(is (equal '(("items:") ("<ol>" "<li>" "first line" "</li>")
("<li>" "second line" "</li>") ("</ol>" "end"))
(apply-line-processors '(("items:") ("#" "first line") ("#"
"second line") ("end")) (list (list-insertion)))))
(is (equal '(("items:") ("<ul>" "<li>" "first line" "</li>")
("</ul>" "<ol>" "<li>" "second line" "</li>") ("</ol>" "end"))
(apply-line-processors '(("items:") ("*" "first line") ("#"
"second line") ("end")) (list (list-insertion)))))
(is (equal '(("items:") ("<ul>" "<li>" "first line" "</li>")
("<ol>" "<li>" "second line" "</li>") ("<li>" "third line" "</li>")
("</ol>" "</ul>" "end"))
(apply-line-processors '(("items:") ("*" "first line") ("##"
"second line") ("##" "third line") ("end")) (list (list-insertion)))))
(is (equal '(("items:") ("<ul>" "<li>" "first line" "</li>")
("<ol>" "<li>" "second line" "</li>") ("</ol>" "<li>" "third line"
"</li>") ("</ul>" "end"))
(apply-line-processors '(("items:") ("*" "first line") ("##"
"second line") ("*" "third line") ("end")) (list (list-insertion)))))
(is (equal '(("items:")
("<ul>" "<li>" "first line" "</li>")
("<ol>" "<li>" "second line" "</li>")
("<ul>" "<li>" "third line" "</li>")
("</ul>" "</ol>" "<li>" "fourth line" "</li>")
("</ul>" "end"))
(apply-line-processors '(("items:") ("*" "first line") ("##"
"second line") ("***" "third line") ("*" "fourth line") ("end")) (list
(list-insertion)))))))
Here there are the details of the frame where LINE-PROCESSORS contains
the closure returned by list-insertion
Cannot funcall macro functions.
[Condition of type KERNEL:SIMPLE-UNDEFINED-FUNCTION]
Restarts:
0: [RETEST] Rerun the test.
1: [IGNORE] Signal a test failure and abort this test.
2: [ABORT] Abort handling SLIME request.
3: [ABORT] Return to Top-Level.
Backtrace:
0: ("DEFUN (SETF MACRO-FUNCTION)" #<#1=unused-arg> #<#1#>)[:OPTIONAL]
1: (APPLY-LINE-PROCESSORS (("items:") ("*" "first line") ("#" "second
line") ("end")) (#<Closure Over Function "DEFUN LIST-INSERTION"
{589E8221}>))
Locals:
FUNCTION = :<NOT-AVAILABLE>
LINE = :<NOT-AVAILABLE>
LINE-PROCESSORS = (#<Closure Over Function "DEFUN
LIST-INSERTION" {589E8221}>)
LINES = (("items:") ("*" "first line") ("#" "second line") ("end"))
RESULT = (("<ul>" "<li>" "first line" "</li>") ("items:"))
[No catch-tags]
2: ("TEST SIGNED-LIST-INSERTION")
3: (IT.BESE.FIVEAM::RETURN-RESULT-LIST #<Function "TEST
SIGNED-LIST-INSERTION" {59450279}>)
4: ((METHOD IT.BESE.FIVEAM::RUN-TEST-LAMBDA NIL
(IT.BESE.FIVEAM::TEST-CASE)) (#(4 3) . #()) #<unused-arg>
#<IT.BESE.FIVEAM::TEST-CASE SIGNED-LIST-INSERTION>)
5: ((METHOD IT.BESE.FIVEAM::RUN-RESOLVING-DEPENDENCIES NIL
(IT.BESE.FIVEAM::TEST-CASE)) (#(2 0 3 3) . #()) #<unused-arg>
#<IT.BESE.FIVEAM::TEST-CASE SIGNED-LIST-INSERTION>)
6: ((METHOD IT.BESE.FIVEAM::%RUN NIL (IT.BESE.FIVEAM::TEST-SUITE))
(#(4 3) . #()) #<unused-arg> #<IT.BESE.FIVEAM::TEST-SUITE LIST-TESTS>)
7: ((METHOD IT.BESE.FIVEAM::%RUN NIL (IT.BESE.FIVEAM::TEST-SUITE))
(#(4 3) . #()) #<unused-arg> #<IT.BESE.FIVEAM::TEST-SUITE ALL-TESTS>)
8: ("DEFUN RUN")
The functions apply-line-processors and list-insertion are used in a
wiki I'm writing using cmucl and aserve, here is the code that use them:
(defmacro wiki-page ((path &key editable) &rest body)
`(:html (:head (:title "Wiki"))
(:body
((:table :border "0" :width "100%" :bgcolor "lightblue")
(:tr (:td (:h2 (:princ (path-multilink ,path))))
((:td :align "right") ((:a :href "view.html") "Wiki Home")))
,(if editable
`(:tr ((:td :colspan "2") ((:a :href (url-with-path "edit.html"
,path)) "Edit this page"))))
((:tr :bgcolor "white") ((:td :colspan "2") ,@body))))))
(defun view-content-page (path)
(html (wiki-page (path :editable t) (:princ (load-content path
#'insert-links #'append-br (list-insertion))))))
Yesterday evening I found out that the problem there is only the first
time I compile and load the system, this is the code I execute:
(load "packages.lisp")
(load (compile-file "packages.lisp"))
(load (compile-file "publish.lisp"))
(load (compile-file "wiki.lisp"))
(load (compile-file "list.lisp"))
(load (compile-file "tests.lisp"))
(load (compile-file "list-tests.lisp"))
When I rexecute the same code the second time there is no problem.
Thanks for the help.
Giannandrea