
Why Lisp macros are cool, a Perl perspective (2005) - ed
http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html
======
randomwalker
Even for those who don't need to be sold on Lisp macros, that was worth
reading just for this sentence (in reference to C++ macros):

 _I forgot what rabid programming language fans are like; they can and will
defend any system, no matter how dysfunctional, as long as it's _their_
dysfunctional sytem._

:-)

------
SwellJoe
Higher Order Perl is a fantastic book, which makes a lot of functional
concepts more immediately usable for non-Lisp dynamic language programmers
(the example language is Perl, but there are projects on the web to convert
the examples to other languages; the concepts apply across most of the popular
dynamic languages).

------
aufreak
Here is a link to the section on "what makes lisp different" that is referred
to in the article -

<http://bit.ly/8yrvC>

------
Scriptor
Question about the code:

    
    
      (defmacro set-sqrt (place v) `(setf ,place (* v v)))
    

What does the comma right before place in its second usage signify?

Also, am I right in assuming that setf turns:

    
    
      (setf (f1 arg1) arg2)

into

    
    
      (setter-for-f1 arg1 arg2)

~~~
tumult
I'm not a CL guy so I don't know how defsetf actually works, but I skipped
down in that link to where that Lisp macro is, and if defsetf works like he
describes (and I don't know if it does), then

    
    
        (setf (f1 arg1) arg2)
    

will cause an error, but

    
    
        (setf (sqrt arg1) arg2)
    

will expand into

    
    
        (setf arg1 (* v v))
    

which, as you can see, is nonsensical in terms of what it looks like he was
trying to do.

~~~
diiq
Yes, as has been pointed out, he is missing a pair of commas (or more
correctly, a patch to ensure that v is evaluated once and only once --- right
now it is evaluated 0 times, and adding 2 commas would make it eval twice.
Using the definition of (square x) is the cleanest way to fix this).

------
swolchok
As a non-Lisper:

In short, macros are cool because, instead of hacking the compiler and
groveling through its weird data structures to add language features, you can
add language features in the language itself, because the language is already
traditionally expressed in parse trees. Phrased this way, I don't see why this
is a life-changing revelation.

------
bkovitz
And yet, still no example of a _useful_ macro.

In C++, you already have assignment. You don't need to roll your own.

~~~
tel
Try this: <http://www.paulgraham.com/onlisp.html>

------
dstein64
Is there any significance to the "=3D" in his code, or are those the same as
the normal equal "="? Thanks.

------
benatkin
For a long while I've thought that Randall Schwartz was the author of Higher
Order Perl. Oops.

