I dont get Macros

Discussion of Common Lisp
nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: I dont get Macros

Post by nuntius » Tue Feb 16, 2010 9:19 am

Destruct1 wrote:DSL are important and arithmetic operations are not special. However it is possible to implement this kind of
behavior in Python (and other languages) with operator overloading.
Unfortunately, operator overloading gives you a limited vocabulary (search the Boost devel list for several debates over operator connotation, or justifying an unusual choice due to precedence rules). Furthermore, operator overloading and other function-based approaches cannot perform code refactoring that requires changing evaluation rules, introducing variables, etc. (unless you're wielding monads in an ML variant). C++ has made great strides using templates for metaprogramming; but I dare you to say templates are easier to comprehend than macros. ;) The Boost Preprocessor library would not be necessary if templates were as powerful as macros.

Suroy
Posts: 46
Joined: Sat Dec 19, 2009 11:20 am

Re: I dont get Macros

Post by Suroy » Tue Feb 16, 2010 9:31 am

If you want to truly bask in the true glory of lisp and macros you should read
http://www.paulgraham.com/onlisptext.html

And then once you think youve seen it all you can take a good look at continuatiosn:
http://common-lisp.net/project/cl-cont/, partial evaluators (hu.dwim.partial-eval), code walkers (hu.dwim.walker), and customizable reader macros (hu.dwim.reader):

All of which (well not the continuations) expands the power of macros! Hail to the macros!

OK, i think paul graham does a better job of selling lisp in the first few pages of on lisp :D

Post Reply