merits of Lisp vs Python

Bill Atkins SPAM-IS-batkins57-FOR-LOSERS at gmail.com
Sun Dec 17 02:28:05 EST 2006


greg <greg at cosc.canterbury.ac.nz> writes:

> André Thieme wrote:
>>  (aif (timeConsumingCalculation)
>>      (use it))
>
> I think the answer is that you just wouldn't do
> that in Python at all. Having magic variables
> spring into existence in your local namespace
> as a side effect of calling something is just
> not Pythonic. (It is very Perlish, on the other
> hand.)

Anaphoric macros are controversial in CL, too, for just that reason.
But there are a parallel set of macros that explicitly bind a variable
so you can get the convenience without the weirdness:

(bif (items (remove-if-not #'useful-p big-list-o-items))
  (format t "~D items~%" (length items))
  (format t "Nothing useful.~%"))

You can rewrite the expression in the grandparent as:

  (aif (result (timeConsumingCalculation))
    (use result)

or, more idiomatically:

  (awhen (result (time-counsuming-calculation))
    (use result))



More information about the Python-list mailing list