Re: A "killer" macro
- From: gisle@xxxxxxxxxxxxxxxx (Gisle Sælensminde)
- Date: 25 Sep 2007 09:57:31 +0200
Eli Bendersky <eliben@xxxxxxxxx> writes:
Hello all,
In short: I'm looking for a "killer" macro - a macro (or a couple of
related ones) that show what Lisp can do and other languages (those
without uniform syntax) can not.
A longer version: Many contemporary languages boast their sharing most
of the functional features of Lisp. Perl, Ruby, Javascript - all have
convenient lists (or arrays), functions as first class objects,
garbage collection, dynamic typing, lexical closures. However, one
thing they lack is uniform syntax, and hence the service of a powerful
built-in macro system such as Common Lisp's "defmacro".
When confronted by fellow programmers with the question "so why is
Lisp so special", I'm looking for that short - not too hard to
understand - snippet of code that will show them *why*. I'm convinced
that such a snippet must involve macros. But all the examples I ran
into so far have been either too simple - and could be easily
implemented another way (for example with Ruby's blocks), or too
complicated.
Any suggestions for such an example ?
I have earlier used an implementation of a lexer macro as an example, see
http://groups.google.no/group/comp.lang.lisp/browse_thread/thread/2d7e3fc62d5cfdbc/a1068634fe42c048?lnk=st&q=darwin-lex&rnum=3#a1068634fe42c048
(Page show just usage, not the implementation, I can post that if you want)
In most languages, the equivalent is an external tool that macine-generate code.
There is also cl-yacc, that define a similar
Another, and a really good example if you are less into compilers and it's tools,
is the binary file macros in Peter Seibels Practical common lisp (chapter 24),
and available online. This is a really good example of good macro usage:
http://www.gigamonkeys.com/book/practical-parsing-binary-files.html
--
Gisle Sælensminde, Phd student, Scientific programmer
Computational biology unit, BCCS, University of Bergen, Norway,
Email: gisle@xxxxxxxxxx
The best way to travel is by means of imagination
.
- Follow-Ups:
- Re: A "killer" macro
- From: Alan Walker
- Re: A "killer" macro
- References:
- A "killer" macro
- From: Eli Bendersky
- A "killer" macro
- Prev by Date: Re: Easy one for you: Funcall secrets ... Mayday!
- Next by Date: Re: Lisp In a Box for Windows Vista
- Previous by thread: Re: A "killer" macro
- Next by thread: Re: A "killer" macro
- Index(es):
Relevant Pages
|