merits of Lisp vs Python

Alex Mizrahi udodenko at users.sourceforge.net
Sat Dec 9 14:40:23 EST 2006


(message (Hello 'Paul)
(you :wrote  :on '(09 Dec 2006 01:01:14 -0800))
(

 PR> If Common Lisp didn't have lexically scoped variables (most Lisp
 PR> dialects before Scheme didn't have them) then it would be very
 PR> difficult to add that with macros.

i think there's some way to hack that. for example, make defun a macro that 
will collect all lexically scoped variable and mangle them. for example:

(defun foo () (let ((i 1)) (print i)))

will be transformed to

(defun foo () (let ((i_foo 1)) (print i_foo)))

(or just some random suffix). this way variables in different functions will 
never collide. maybe there's a catch somewhere, but that should look very 
close to lexical variables.

 PR> Do you seriously think lexical scoping is the last word in language
 PR> features and that there's now nothing left in other languages that
 PR> can't straightforwardly be done in CL?  Hint:
 PR> call-with-current-continuation (also known as call/cc).

there's nothing impossible :)
we even have a lib for nondeterministic calculations -- Screamer, that's 
much much more cool than that call/cc..

(defun pythagorean-triples (n)
 (all-values
  (let ((a (an-integer-between 1 n))
        (b (an-integer-between 1 n))
        (c (an-integer-between 1 n)))
   (unless (= (+ (* a a) (* b b)) (* c c)) (fail))
   (list a b c))))

you define ranges for variables, define constraints (in a form very close to 
normal lisp code) and then just say -- all-values, or solutions (first thing 
that satisfies constaints).

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity") 





More information about the Python-list mailing list