Casting SPELs in Lisp - The Comic Book!

34 views
Skip to first unread message

drc...@gmail.com

unread,
Dec 5, 2004, 8:58:46 PM12/5/04
to
Hi fellow LISPers, I have just slaved away at a new online tutorial for
newbies or those with no previous LISP experience. (NObies? :-)

http://www.lisperati.com

(be sure to read the addendum at
http://www.lisperati.com/addendum.html
before suggesting any corrections...)

The goal of this tutorial is twofold:

1. To take a non-LISP programmer along the straightest possible line so
that he/she can appreciate some of the coolest, tastiest nuggets of
programming power that LISP has to offer.

2. To explore the idea that Macros can be taught far more easily if
they are given a different name, due to the semantic load present in
this overused term. In my tutorial, I suggest the term SPEL as a simple
synonym (replacement?) of "Macro" that offers many advantages for
reasons outlined in the following essay:

http://www.lisperati.com/no_macros.html

Any feedback is greatly appreciated!
--
Conrad Barski, M.D. (concatenate 'string "drcode@gm" "ail.com")

Kenneth Tilton

unread,
Dec 5, 2004, 11:09:43 PM12/5/04
to
In article <1102298326.4...@z14g2000cwz.googlegroups.com>,
drc...@gmail.com wrote:

That is <expletive deleted> awesome. Mind you, I am not good at reading,
so I just looked at the pictures. Brilliant. And I am glad to see QUOTE
dealt with up front, given the newbie fatality rate on that issue lately.

:)

kenny

OSU

unread,
Dec 6, 2004, 12:10:15 AM12/6/04
to
drc...@gmail.com wrote:

> 1. To take a non-LISP programmer along the straightest possible line so
> that he/she can appreciate some of the coolest, tastiest nuggets of
> programming power that LISP has to offer.

This is really good! I did some LISP, but never got around to macros (course
too short). I see what PG means by 'build the language up to the app'.. the
game-action macro was an inspired choice (so was the choice of game
programming). Glad you tackled the meaty problems, I think newbies spend
too much time mucking about with basic stuff & end up trying to do things
the non-lispy way.

cheers,
N

PS what I take away from this is that to write spels you need a basic
similarity of textual structure in the source code.. is that correct? that
ultimately it's just a source level transformation? Or is this my C macro
bias at work?

---
Nandan Bagchee
CIS / Ohio State
last...@cse.ohiodashstate.edu

Eventually the pimps and drug dealers notice that the doctors and lawyers
have switched from Cadillac to Lexus, and do the same.
-- Paul Graham

Wade Humeniuk

unread,
Dec 6, 2004, 1:08:21 AM12/6/04
to
OSU wrote:

>
> PS what I take away from this is that to write spels you need a basic
> similarity of textual structure in the source code.. is that correct? that
> ultimately it's just a source level transformation? Or is this my C macro
> bias at work?
>

It helps to keep the basic list structure when writing macros (spels).
However it is not mandatory. There are macros which can transform
things like infix math into Lisp sexpr math. Also the phrase "just
a source level transformation" is misleading. The tranformation of
a macro form to another can be done using the whole functionality of the
Lisp image. Variables can be created, context can be taken into
consideration, connections to web servers made, helper functions
can be created and compiled. Even foreign C code could be written,
compiled and dynamically linked with a Lisp's FFI. In C it is just
simple-minded substitution.

Potential Non Lispy Macro Examples:

(setf *calgary-merchants*
#!sql: select merchant.id from merchants where (merchant.city = 'Calgary');)

(publish "/echopage.html"
:virtual-host "home.com"
:mime-type "text/html"
:content
#!html: <html>
<head><title>Embedded Lisp Web Page</title></head>
<body>
You are accessing this page from !*source-ip-address*
</body>
</html>)

Wade


Pascal Bourguignon

unread,
Dec 6, 2004, 1:09:09 AM12/6/04
to
OSU <osuf...@mailite.com> writes:
> PS what I take away from this is that to write spels you need a basic
> similarity of textual structure in the source code.. is that correct? that
> ultimately it's just a source level transformation? Or is this my C macro
> bias at work?

Not exactly. That's the easiest, but you can have some other occurences.


(defmacro mul (x y)
(cond
((integerp x) ; a literal constant
(cond
((= 0 x)
0)
((= x (expt 2 (truncate (log x 2))))
`(ash y , (truncate (log x 2))))
((< x 10)
(let ((vs (gensym))(vy (gensym)))
`(let ((,vs 0)(,vy ,y)) (dotimes (i ,x) (incf s ,vy)))))
(t
`(* ,x ,y))))
(t ; a variable
`(* ,x ,y))))

(macroexpand-1 '(MUL 0 y))
==> 0, T
(macroexpand-1 '(MUL 4 y))
==> (ASH Y 2), T
(macroexpand-1 '(MUL 5 y))
==> (LET ((#:G1293623 0) (#:G1293624 Y))
(DOTIMES (I 5) (INCF S #:G1293624))), T
(macroexpand-1 '(MUL x y))
==> (* X Y), T


The textual structure of the generate source can vary quite a lot, and
still implement the same _abstraction_.

--
__Pascal Bourguignon__ http://www.informatimago.com/
The world will now reboot; don't bother saving your artefacts.

Arthur Lemmens

unread,
Dec 6, 2004, 4:33:34 AM12/6/04
to drc...@gmail.com
Conrad Barski wrote:

> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)
>
> http://www.lisperati.com

Very impressive!! Great drawings, clear explanation, nice example code.
It's fantastic to see something so totally different from the usual boring
explanations of quote and macros.

The only thing I missed was a "To Be Continued" line at the end. (Oh, and
there's is a misplaced "for" and a missing "-ing" in the sentence "Even for
experienced LISP programmers would have to put some thought into create a
monstrosity like this".)

It would be great if you could find a publisher for this. Maybe Markus Fix
would be interested?

--
Arthur

Markus Fix

unread,
Dec 6, 2004, 4:47:37 AM12/6/04
to
drc...@gmail.com wrote:
> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)
>
> http://www.lisperati.com

Beautiful! Simply amazing!

> 2. To explore the idea that Macros can be taught far more easily if
> they are given a different name, due to the semantic load present in
> this overused term. In my tutorial, I suggest the term SPEL as a simple
> synonym (replacement?) of "Macro" that offers many advantages for
> reasons outlined in the following essay:

SPEL is certainly closer to the truth about Lisp macros. A SPEL enlarges
your active vocabulary, but it drains your Mana during debugging. Very appropriate.

-fix

--
------- Markus Fix http://www.bookfix.com/ --------
--------Creating the Programmer's Library----------

Lars Brinkhoff

unread,
Dec 6, 2004, 5:26:09 AM12/6/04
to
It's the "Beginning Forth" of Lisp!

--
Lars Brinkhoff, Services for Unix, Linux, GCC, HTTP
Brinkhoff Consulting http://www.brinkhoff.se/

Adam Warner

unread,
Dec 6, 2004, 6:06:03 AM12/6/04
to
Hi drcode,

> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)
>
> http://www.lisperati.com
>
> (be sure to read the addendum at
> http://www.lisperati.com/addendum.html before suggesting any
> corrections...)

Bravo! Extraordinary!

One more thing we left out of the code is the defparameter command
for creating global variables- Instead, we just used setf to declare
variables (which works, but is considered bad style...)

While I understand this approach within a REPL style tutorial it would be
nice to see you fix the final code: <http://www.lisperati.com/code.html>
(that is replace each top-level setf with defparameter and add a comment
to the code explaining why you did this).

Regards,
Adam

Paul Foley

unread,
Dec 6, 2004, 6:24:09 AM12/6/04
to
On 5 Dec 2004 17:58:46 -0800, drcode wrote:

> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)

> http://www.lisperati.com

> Any feedback is greatly appreciated!

Please substitute "Lisp" for "LISP" throughout.

[And "Allegro Common Lisp" for "Allegro LISP", I guess]

--
If that makes any sense to you, you have a big problem.
-- C. Durance, Computer Science 234
(setq reply-to
(concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))

Lars Brinkhoff

unread,
Dec 6, 2004, 8:52:37 AM12/6/04
to
> It's the "Beginning Forth" of Lisp!

"Starting Forth", that is.

drc...@gmail.com

unread,
Dec 6, 2004, 9:20:36 AM12/6/04
to
I'll do that!

--Conrad

drc...@gmail.com

unread,
Dec 6, 2004, 9:21:32 AM12/6/04
to
I've gotten several replies about the upcase Lisp and will make the
requisite change.

-Conrad

drc...@gmail.com

unread,
Dec 6, 2004, 9:23:12 AM12/6/04
to
good idea- I will do that!

-Conrad

drc...@gmail.com

unread,
Dec 6, 2004, 9:24:07 AM12/6/04
to
I have gotten several replies about the upcase Lisp and will make the
change.

Thanks!

--Conrad

Paolo Amoroso

unread,
Dec 6, 2004, 9:19:28 AM12/6/04
to
drc...@gmail.com writes:

> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)
>
> http://www.lisperati.com

Holy bit! :) By the way, "lisperati" sounds similar to "disperati",
which is the Italian for "desperate".

Thanks for the great resource,


Paolo
--
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Recommended Common Lisp libraries/tools (see also http://clrfi.alu.org):
- ASDF/ASDF-INSTALL: system building/installation
- CL-PPCRE: regular expressions
- UFFI: Foreign Function Interface

Szymon

unread,
Dec 6, 2004, 12:15:20 PM12/6/04
to
Paolo Amoroso <amo...@mclink.it> writes:

> drc...@gmail.com writes:
>
>> Hi fellow LISPers, I have just slaved away at a new online tutorial for
>> newbies or those with no previous LISP experience. (NObies? :-)
>>
>> http://www.lisperati.com
>
> Holy bit! :)

Yes, _very_ nice stuff.

> By the way, "lisperati" sounds similar to "disperati", which is the
> Italian for "desperate".

My association was with 'iluminati' or 'illuminati' :P

Regards, Szymon.

Message has been deleted

drc...@gmail.com

unread,
Dec 6, 2004, 12:41:28 PM12/6/04
to
The intention was to reference "literati" and "digerati".

Given the cult-like nature of the lisp community, I suppose
"illuminati" works as well :)

"Desperate" i suppose isn't totally unreasonable either ;)

-Conrad

Ingvar wrote:


> Szymon <r5z-u2...@o2.pl> writes:
>
> > Paolo Amoroso <amo...@mclink.it> writes:
> >
> > > drc...@gmail.com writes:
> > >
> > >> Hi fellow LISPers, I have just slaved away at a new online
tutorial for
> > >> newbies or those with no previous LISP experience. (NObies? :-)
> > >>
> > >> http://www.lisperati.com
> > >
> > > Holy bit! :)
> >
> > Yes, _very_ nice stuff.
>

> It was certainly interesting.


>
> > > By the way, "lisperati" sounds similar to "disperati", which is
the
> > > Italian for "desperate".
> >
> > My association was with 'iluminati' or 'illuminati' :P
>

> Oh? I was thinking "literati".
>
> //Ingvar
> --
> "No. Most Scandiwegians use the same algorithm as you Brits.
> "Ingvar is just a freak."
> Stig Morten Valstad, in the Monastery

Pascal Costanza

unread,
Dec 6, 2004, 1:20:37 PM12/6/04
to

Markus Fix wrote:
> drc...@gmail.com wrote:
>
>> Hi fellow LISPers, I have just slaved away at a new online tutorial for
>> newbies or those with no previous LISP experience. (NObies? :-)
>>
>> http://www.lisperati.com
>
> Beautiful! Simply amazing!

I'd like http://www.lisperati.com/different.jpg as a T-shirt. ;)


Pascal

--
The big bang way only works for god, everybody else has to use
evolution. - David Moon

Svein Ove Aas

unread,
Dec 6, 2004, 1:23:12 PM12/6/04
to
Pascal Costanza wrote:

>
> Markus Fix wrote:
>> drc...@gmail.com wrote:
>>
>>> Hi fellow LISPers, I have just slaved away at a new online tutorial for
>>> newbies or those with no previous LISP experience. (NObies? :-)
>>>
>>> http://www.lisperati.com
>>
>> Beautiful! Simply amazing!
>
> I'd like http://www.lisperati.com/different.jpg as a T-shirt. ;)
>

Ooh... t-shirty goodness...

We could probably get cafepress to do that.

Emre Sevinc

unread,
Dec 6, 2004, 2:54:07 PM12/6/04
to
drc...@gmail.com writes:

> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)
>
> http://www.lisperati.com
>
> (be sure to read the addendum at
> http://www.lisperati.com/addendum.html
> before suggesting any corrections...)
>

My first impression: Lovely!

My demand: I want to translate it into Turkish,
including the baloons. If you can bother yourself
to put my translations in the baloons, I can handle
the remaining work by myself. I want to introduce
Common Lisp to Turkish speaking computer community
however there are many programmers who do not know
English very well so a fancy beginner tutorial like
that one, in their mother tongue would motivate them
to learn more Common Lisp (and English as well :)

--
Emre Sevinc

eMBA Software Developer Actively engaged in:
http:www.bilgi.edu.tr http://ileriseviye.org
http://www.bilgi.edu.tr http://fazlamesai.net
Cognitive Science Student http://cazci.com
http://www.cogsci.boun.edu.tr

drc...@gmail.com

unread,
Dec 6, 2004, 2:59:21 PM12/6/04
to
If you give me the translations, I'll be glad to change the captions.
-Conrad (concatentate 'string "drcode@gm" "ail.com")

Tayssir John Gabbour

unread,
Dec 6, 2004, 3:17:35 PM12/6/04
to
Pascal Costanza wrote:
> I'd like http://www.lisperati.com/different.jpg as a T-shirt. ;)

I seriously thought about making that the picture, when I posted it on
the c2 wiki. It really doesn't seem like there are enough crazy Lisp
flamewars there right now.

There's something about that picture.


> The big bang way only works for god, everybody else has to use
> evolution. - David Moon

A quick Google didn't pick that quote up. Was that from some talk?
MfG,
#\Tayssir

drc...@gmail.com

unread,
Dec 6, 2004, 3:25:25 PM12/6/04
to
If somebody else wants to take the initiative of doing some marketing
and creating a nice website for it (i.e. more than just the generic
cafepress page), I'd be glad to take the Lisp vs. other languages motif
from the blackboard of the cartoon and make it into a more polished
design for a tshirt.
--Conrad (concatenate 'string "drcode@gm" "ail.com")

Dirk Gerrits

unread,
Dec 6, 2004, 3:26:42 PM12/6/04
to
drc...@gmail.com writes:

> Hi fellow LISPers, I have just slaved away at a new online tutorial for
> newbies or those with no previous LISP experience. (NObies? :-)
>
> http://www.lisperati.com

This is just great stuff! I don't know what more to say. :)

Just a couple of small nits:

1. The "old", pre-GAME-ACTION version of WELD does not SETF
*CHAIN-WELDED*.

2. The first line of the body of the GAME-ACTION SPEL is indented too
much.

3. Indentation is accomplished with a mixture of tabs and spaces.
People who copy & paste the code and use a tab-width different from
yours might find the indentation of the code a bit odd. I greatly
prefer the use of spaces only.

Kind regards,

Dirk Gerrits

drc...@gmail.com

unread,
Dec 6, 2004, 3:43:24 PM12/6/04
to
great feedback! I'll make those changes.

-Conrad

drc...@gmail.com

unread,
Dec 6, 2004, 3:43:44 PM12/6/04
to

Emre Sevinc

unread,
Dec 6, 2004, 4:19:25 PM12/6/04
to
drc...@gmail.com writes:

> If you give me the translations, I'll be glad to change the captions.
> -Conrad (concatentate 'string "drcode@gm" "ail.com")
>

Cool. BTW, what about the licence, copyright, etc. situation
of the text? Which one do you prefer? To publish the
Turkish translation (with Turkish baloon captions)
on your website or do you consider it be published on
some other mirror sites, too?

Pascal Costanza

unread,
Dec 6, 2004, 4:43:33 PM12/6/04
to

Tayssir John Gabbour wrote:

>>The big bang way only works for god, everybody else has to use
>>evolution. - David Moon
>
> A quick Google didn't pick that quote up. Was that from some talk?

It's from one of the "dynamic languages wizards" panels - see
http://www.ai.mit.edu/projects/dynlangs/wizards-panels.html


Pascal

--

Alex Mizrahi

unread,
Dec 6, 2004, 5:04:26 PM12/6/04
to
(message (Hello 'drc...@gmail.com)
(you :wrote :on '(5 Dec 2004 17:58:46 -0800))
(

d> http://www.lisperati.com

looks like here's a bug:

(defun walk-direction (direction)
(let ((next (assoc direction (cdr (assoc *location* *map*)))))
(cond (next (setf *location* (third next)) (look))
(t '(you cant go that way.)))))

cdr in (cdr (assoc *location* *map*)) should be cddr, as it was in
#'describe-paths

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
(prin1 "Jane dates only Lisp programmers"))


drc...@gmail.com

unread,
Dec 6, 2004, 5:06:43 PM12/6/04
to
The text has a creative commons license (you can do whatever you want
with it, as long as you give me credit)

> To publish the
> Turkish translation (with Turkish baloon captions)
> on your website or do you consider it be published on
> some other mirror sites, too?

I'll put it on my webserver as a link on the main page- If you want to
put it on a separate site as well, mirrors are no problem.

-Conrad

drc...@gmail.com

unread,
Dec 6, 2004, 5:13:16 PM12/6/04
to
great catch! luckily, its not noticable- Still, a pretty bad mistake...
-Conrad

Raffael Cavallaro

unread,
Dec 6, 2004, 7:00:59 PM12/6/04
to
On 2004-12-06 15:25:25 -0500, drc...@gmail.com said:

> I'd be glad to take the Lisp vs. other languages motif
> from the blackboard of the cartoon and make it into a more polished
> design for a tshirt.

I think you might want to include the Lisp Wizard as well - he adds
quite a bit to that particular cartoon (IMHO, of course).

Well done all around - I thoroughly enjoyed it.

regards,

Ralph

philip...@gmail.com

unread,
Dec 6, 2004, 7:51:55 PM12/6/04
to
That's awesome!
Very creative to make the code a text adventure game. As well as
explaining the basic clearly and non-guruish-ly :)
I've already refered a freiend to it.

BTW, google groups 2 kicks butt!!!
--
Certum quod factum.
Philip Haddad

philip...@gmail.com

unread,
Dec 6, 2004, 7:52:29 PM12/6/04
to

Alex Mizrahi

unread,
Dec 6, 2004, 8:12:28 PM12/6/04
to
(message (Hello 'drc...@gmail.com)
(you :wrote :on '(6 Dec 2004 14:13:16 -0800))
(

d> great catch! luckily, its not noticable- Still, a pretty bad
d> mistake...

i think plists can decrease confusion with all this cddr, second, third..

Szymon

unread,
Dec 6, 2004, 8:46:23 PM12/6/04
to
"Alex Mizrahi" <udod...@hotmail.com> writes:

Hi.

> (message (Hello 'drc...@gmail.com)
> (you :wrote :on '(6 Dec 2004 14:13:16 -0800))
> (
>
> d> great catch! luckily, its not noticable- Still, a pretty bad
> d> mistake...
>
> i think plists can decrease confusion with all this cddr, second, third..

or maybe symbol-macros to "rename" cddr, second, third...

Btw, I think that present state is OK. Do not overkill simple things...

Regards, Szymon.

ps. I just used plists in toy-blog-code-snippet --
I'm not very impressed...
url: [ http://lisp.jogger.pl/comment.php?eid=78513 ].

William Bland

unread,
Dec 6, 2004, 11:05:17 PM12/6/04