Subject: Re: What is the main advantage of macros over functions?
From: (Rob Warnock)
Date: Thu, 05 Jan 2006 05:28:17 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Majorinc, Kazimir  <false@email.address> wrote:
| I've frequently read that macros are one of the most important 
| strengths of Lisp, however, I do not understand why. 
| Am I missing something here? 

Yes. Take a look at, say, HTOUT <> or
CL-WHO <>, both of which let you write
things like this:

    (let ((title "Simple Test Page"))
      (with-html-output (s *standard-output*)
	  (:head (:title title)) (lfd)
	  ((:body :bgcolor "#d0d0ff")
	   (:h1 title) (lfd)
	   "This is a small demo table:" (lfd)
	   (:table (lfd)
	     (:tr (:th "i") (:th "2^i") (:th "10^i")) (lfd)
	     (loop for i below 5
		   for 2^i = (expt 2 i)
		   and 10^i = (expt 10 i) do
	       (htm (:tr (:td i) (:tr 2^i) (:tr 10^i))

and get this output:

    <HTML><HEAD><TITLE>Simple Test Page</TITLE></HEAD>
    <BODY BGCOLOR='#d0d0ff'><H1>Simple Test Page</H1>
    This is a small demo table:

Yes, you can do HTML generation without macros, but it
tends to be ugly and full of deeply-nested LAMBDAs...


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607