Subject: Re: What is the main advantage of macros over functions?
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 06 Jan 2006 07:24:49 -0600
Newsgroups: comp.lang.lisp
Message-ID: <PJadnYvBstk88iPeRVn-rg@speakeasy.net>
Rainer Joswig  <joswig@lisp.de> wrote:
+---------------
| <ocorrain@yahoo.com> in m2k6debzm1.fsf@Cascade.local:
| > rpw3@rpw3.org (Rob Warnock) writes:
| >> (let ((title "Simple Test Page"))
| >>   (with-html-output (s *standard-output*)
| >>     (:html
| >>       (:head (:title title)) (lfd)
...
| > And indeed, you can do something like:
| > (defmacro with-standard-page ((title &key (stylesheet "standard.css"))
| >                               &body body)
...
| 
| Why would you write it as a macro? This has only disadvantages.
| That's exactly the place where I would NOT use macros. Where macros even
| are EVIL.
| I'm using functions for it.
| 
| (defun generate-benchmark-page (url stream)
|   (generate-basic-page
|    url stream
|    :render-function (lambda (url stream)
|                       (declare (ignore url))
|                       (render-benchmark-table
|                        (list *benchmark-values* *benchmark1-values*
|                              *benchmark2-values* *benchmark3-values*
|                              *benchmark4-values*)
|                        stream
|                        :table-type :horizontal))
|    :title "Rainer Joswig's Home, Lisp Benchmarks"))
+---------------

O.k., you caught me. I don't actually use macros for "wrapper" pages
either. The RESULTS-TEMPLATE-PAGE I mentioned in an earlier reply is
actually a function, that takes a LAMBDA or oter function as a callback.

You're right, such functions are less code-wasteful, and easier to
debug.

But WITH-HTML-OUTPUT... that one *should* be a macro!


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607