What can you do in LISP that you can't do in Python

Remco Gerlich scarblac at pino.selwerd.nl
Wed May 16 12:18:10 EDT 2001


Thomas Bellman <bellman at lysator.liu.se> wrote in comp.lang.python:
> Parsing and executing is two entirely different things.  I was
> not talking about just passing a bit of code to an 'execute'
> procedure (which is called eval in LISP, exec in Python, and
> I-don't-know-what in TCL); I was talking about parsing the code
> in order to be able to modify it.  You don't get that for free
> just because you have the code in a string and the 'execute'
> procedure takes a string as its argument.

You do in Tcl, because everything is a string. *And*, strings can be used as
lists. The syntax for seeing a string as a list is exactly Tcl's syntax.
So

"command arg {second arg}"

is a) a string, b) a bit of Tcl code, that when exec'ed calls command with
two arguments, 'arg' and 'second arg', and c) a list with three elements,
'command', 'arg' and 'second arg'.

Because of c), it's easy to manipulate, it's basically the same situation as
Lisp.

The { } mean that the second list isn't evaluated when the code is executed
(like a '(quoted list) in Lisp). If they were [ ], the command "second arg"
would have been evaluated first. It's really a lot like Lisp, in this
respect.

It's been a few years since I used Tcl, so this could be inaccurate. I found
Perl after a while, and never looked back. A few months later I found
Python...

-- 
Remco Gerlich



More information about the Python-list mailing list