Why is Python popular, while Lisp and Scheme aren't?

Pascal Costanza costanza at web.de
Mon Nov 11 05:33:43 EST 2002


Greg Ewing wrote:
> Pascal Costanza wrote:
> 
>> In Common Lisp, you can have:
>>
>> (paint circle :on canvas :at point)
>>
>> Given that you have defined paint as follows:
>>
>> (defun paint (&key on at)
>>    ...)
> 
> Python still goes one better, because (for user-defined
> methods at least) you can supply arguments by keyword even
> if they *haven't* been declared that way!

No problem.

(defun paint (&key on at &allow-other-keys)
    ...)

;-)

Lisp's argument options are rather complete. Here's another nice example.

(defun test (&key (arg nil arg-supplied))
    (if arg-supplied
       (format t "The argument was ~A.~%" arg)
       (format t "No argument was supplied.")))

 > (test :arg 5)
The argument was 5.

 > (test :arg nil)
The argument was nil.

 > (test)
No argument was supplied.


Pascal

-- 
Pascal Costanza               University of Bonn
mailto:costanza at web.de        Institute of Computer Science III
http://www.pascalcostanza.de  Römerstr. 164, D-53117 Bonn (Germany)




More information about the Python-list mailing list