Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Ted Leung on the air: Open Source, Java, Python, and ...
Sat, 10 May 2003
Testing and dynamic typing
I was going tg write a post about testing and dynamic typing, but Patrick Logan and Jarno Virtanen beat me to it.
[00:16] |
[computers/programming] |
# |
TB |
F |
G |
0 Comments |
macros vs keyword messages
It's great when you actually learn something new, and I seem to do that quite frequently in the weblog world. Here's today's:
Patrick Logan, who I remember from comp.lang.dylan days, had this to say about syntax extension:
[00:12] |
[computers/programming/lisp] |
# |
TB |
F |
G |
3 Comments |
While Smalltalk doesn't have syntax macros like Lisp, Smalltalk *does* have simpler block syntax and keyword arguments.This use of keyword messages and closures is really interesting. In Chapter 8 of On Lisp, Graham lists 6 reasons to use macros. Delaying or altering evaluation is an aspect of the first 4 reasons. Reason 5 involves using the calling environment, which you very rarely want to do, reason 6 involves using a new lexical environment, which you also rarely want to do, and reason 7 is inlining which is a performance annotation. I'd be curious to see some examples of this type of Smalltalk code.The effect is that new keyword messages can take block closures, which essentially delay evaluation until the method behind the message decides to evaluate them, and the message send looks an awful lot like new syntax, very clean.
Many uses of macros in Lisp, frankly, are simply created to hide the appearance of the lambda keyword. Of course there are more "legitimate" uses of macros, but these are less common.