What does Python fix?
Huaiyu Zhu
huaiyu at gauss.almadan.ibm.com
Thu Jan 17 23:16:00 EST 2002
On 17 Jan 2002 18:30:04 -0500, François Pinard <pinard at iro.umontreal.ca> wrote:
>
>Python, roughly summarised, has statements and expressions. Indentation is
>used for statements only. As for expressions, Python is similar to LISP,
>in that indentation has no meaning, and parentheses are often necessary.
>We do agree that priority rules for operators alleviate the need of many
>parentheses in Python.
>
>LISP has nothing but expressions, or at least, theoretically. In practice,
>people have a feeling of writing LISP statements, but the distinction is
>fully subjective, a bit fuzzy, and not necessary. For being able to use
>indentation to replace parentheses, this distinction would probably need
>to be formalised and made unbearably rigid.
One possible distinction is between pure functions and special forms.
Here's an example of using Python statements and Lisp expressions:
def (f x y):
a = (g (h x) y)
if (w a): x
else: (- y)
I've tried this notation in my own notes. It sometimes helps me think about
abstraction when doing refactoring, esp when functions are being generated
and passed around. I can't specify why. And YMMV, of course.
>
>Also remember that LISP allows arbitrarily complex expressions to be used
>in all positions of a function call, that is, for any argument or for the
>function itself. I do not see how one could unambiguously express such
>things through pure indentation. By comparison, Python needs verbosity to
>render such intents. Even if it was possible to purely rely on indentation,
>the code would use a lot more vertical space, as the current LISP notation
>is rather compact. This bloat will not be welcome.
>
Example please?
Huaiyu
More information about the Python-list
mailing list