Python syntax in Lisp and Scheme

Steve VanDevender stevev at hexadecimal.uoregon.edu
Sun Oct 5 02:58:32 EDT 2003


"Terry Reedy" <tjreedy at udel.edu> writes:

> Lisp (and possibly other languages I am not familiar with) adds the
> alternative of *not* evaluating arguments but instead passing them as
> unevaluated expressions.  In other words, arguments may be
> *implicitly* quoted.  Since, unlike as in Python, there is no
> alternate syntax to flag the alternate argument protocol, one must, as
> far as I know, memorize/learn the behavior for each function.  The
> syntactic unification masks but does not lessen the semantic
> divergence.  For me, it made learning Lisp (as far as I have gotten)
> more complicated, not less, especially before I  'got' what going on.

What you're talking about are called "special forms" and are definitely
not functions, and are used when it is semantically necessary to leave
something in an argument position unevaluated (such as in 'cond' or
'if', Lisp 'defun' or 'setq', or Scheme 'define' or 'set!').
Programmers create them using the macro facilities of Lisp or Scheme
rather than as function definitions.  There are only a handful of
special forms one needs to know in routine programming, and each one has
a clear justification for being a special form rather than a function.

Lisp-family languages have traditionally held to the notion that Lisp
programs should be easily representable using the list data structure,
making it easy to manipulate programs as data.  This is probably the
main reason Lisp-family languages have retrained the very simple syntax
they have, as well as why there is not different syntax for functions
and special forms.

> Question: Python has the simplicity of one unified assignment
> statement for the binding of names, attributes, slot and slices, and
> multiples thereof.  Some Lisps have the complexity of different
> functions for different types of targets: set, setq, putprop, etc.
> What about Scheme ;-?

Scheme has 'define', 'set!', and 'lambda' for identifier bindings (from
which 'let'/'let*'/'letrec' can be derived), and a number of mutation
operations for composite data types: 'set-car!'/'set-cdr!' for pairs,
'vector-set!' for mutating elements of vectors, 'string-set!' for
mutating strings, and probably a few others I'm forgetting.

-- 
Steve VanDevender  "I ride the big iron"  http://jcomm.uoregon.edu/~stevev
stevev at hexadecimal.uoregon.edu  PGP keyprint 4AD7AF61F0B9DE87 522902969C0A7EE8
Little things break, circuitry burns / Time flies while my little world turns
Every day comes, every day goes / 100 years and nobody shows -- Happy Rhodes




More information about the Python-list mailing list