"Christian Neukirchen" <chneukirchen@gmail.com> schrieb im Newsbeitrag news:m2br96vgn3.fsf@lilith.local...
Csaba Henk <csaba@phony_for_avoiding_spam.org> writes:
(snip)
Common Lisp:
(dolist (a (list dog cat cow))
(squeak a));; alternatively:
(mapc #'squeak (list dog cat cow));; AFAICS, there is no each_with_index, therefore we use LOOP.
;; Paul Graham would define a new macro
(loop for a in (list dog cat cow)
counting a into i
do (say a (format nil "I'm the ~:R animal~%" i))) ; feat. english numbersNote that in "foreach(i,a,a squeak)" there is no syntactic difference
between the index/value pair which are to be used as immediate values
and the "block argument", to say it in ruby lingo, which is to be
run in each iteration. This phenomenon becomes much more interesting
when you discover you can as well write methods like this.This behavior can be done trivially with macros in Lisp.
So the point is that you can get "lisp powa" in a modern scripting
language as well without burying yourself under tons of parens and
whew-how-the-heck-should-I-name-this-one like function names.I don't think there were *too* many parentheses in above code, were
there?
No.
Also, the method names were totally readable. (From MAPC, you
can at least guess that it maps a sequence. MAPC has the advantage of
not collecting the results. If you dont like the name of MAPC, you
are free to rename it as you like. Don't expect anyone to understand
that. :-))
Well, yes, but it's not only method names. It's the way you have to group things together plus the multitude of methods / ways to do certain things. And probably it's also the power of macros that make Lisp code difficult to comprehend for starters: a function call and a macro call look totally alike on the syntactical level yet they are so totally different (the most significant difference being the point in time when something is evaluated if my Lisp knowledge doesn't betray me). And then you have these different ways of quoting inside a macro...
I readily believe that Lisp is extraordinary productive - and I admire Lisp solutions once in a while. But I've never been exposed to it long enough to really embrace it. Maybe I've done too much procedural and object oriented development - or it's just that my brain is more suited to OO thinking, dunno... ![]()
If someone out there knows a Common-Lisp-in-30-days-guaranteed-comprehension tutorial, let me know and I'll might give Lisp another try.
Thanks for listening and sorry for the noise
robert