[OT] Lisp's "and more", was Re: Who modified my local variable?

Shane Hathaway shane at hathawaymix.org
Tue Jun 13 21:00:54 MDT 2006


Levi Pearson wrote:
> What do s-expressions buy you?  Easy code transformation.  Because a
> lisp program is essentially a textual representation of its abstract
> syntax tree, it is very simple to programmatically analyze and transform
> the program.  This brings us to...

I've done this with Python's compiler module before.  The compiler
module produces an abstract syntax tree that's much easier to interpret
and modify than what the parser module produces.  I used AST
transformations to implement restricted code execution in Zope, and
others have improved the transformations.  (That code is now protecting
thousands of web sites... I hope we got it right. ;-) )

The compiler module is fairly hard to use that way, though.  The Python
community is working on a replacement module.

> The macro facility is one of the primary reasons that lisp is so
> flexible and has adopted so many different programming paradigms. 
> Macros have been used to create object systems, aspect oriented
> programming systems, advanced flow control mechanisms, and all sorts of
> other experimental stuff, some of which was later added to the language
> itself.

People long for macros in Python.  I think Guido shies away from macro
adoption because it could easily lead to a rapid divergence in code
styles, making it difficult to maintain the level of interoperability
Python currently has.  Do macros reduce interoperability?  If two
programmers use a different set of macros, can they join their code?
Can you generally pick up a random bit of Lisp code and use it in your
application, like you can in Python?

Most recent Python language proposals could be implemented with macros.
 I think Guido prefers to be the shepherd of all code at that level.  A
few dedicated hackers manage to implement macro-like functionality with
decorators.

> 3. Image-based development:  This one is not unique, as Smalltalk does
> it even better.  What this means, though, is that running Lisp systems
> are very dynamic, and updates/recompilation can be done without stopping
> the running programs.  The compiler and the read-eval-print loop are
> built into the runtime system, and any aspect of the runtime system can
> be updated on-the-fly.  This is wonderful for two different kinds of
> things, exploratory programming and patching high-availability systems
> with no downtime.

Python can do this too, although people generally avoid it because
restarting the process has more predictable effects.

Shane




More information about the PLUG mailing list