Csaba Henk <csaba / phony_for_avoiding_spam.org> writes:

> On 2005-03-25, Glenn Parker <glenn.parker / comcast.net> wrote:
>> Csaba Henk wrote:
>>> Pall: Even though popular scripting languages such as Python, Perl, Tcl,
>>> PHP, Javascript are all very high-level languages, they are all based on
>>> an text based idiom. [...] Representing code as abstract syntax trees
>>> and not streams of characters is central to huge advances in programmer
>>> efficiency and simplicity.
>>
>> I chuckled when I read that.  The secret to "huge advances" is, wait for 
>> it... LISP!  Only we'll have to drop that antiquated textual 
>> representation stuff for something (?) better.  Too much PHP must rot an 
>> important area of the brain, the same way candy affects your teeth.  :)
>
>  :)
>
> Recently I got quite fond of Io, http://www.iolanguage.com.
>
> Io supports all the lispy stuff and even more (no difference between
> object and binding; function, closure, method, lambda, macro-like
> parsetree tweakers are all the same; and not *almost* everything is
> message sending to an object, like in Ruby or Smalltalk, but
> *everything*, perdiod). And it has a much more friendly syntax than than
> of Lisp. Slightly more verbose than Ruby, but still an agile language.

(Please note that I'm biased due to my Lisp knowledge.)  I actually
think Io's syntax is horrible compared to Lisp. :-) I like the small
size, the prototyped object system and some other nifty features
(transparent futures etc.) of IO, but the syntax is so "bare", it's
really annoying.  Heck, I think even JavaScript would be more
convenient. ;-)

> Ruby:
>
> [dog, cat, cow].each { |a| a.squeak }
> [dog, cat, cow].each_with_index { |a,i| a.say "I'm the #{i}-th animal"  }
>
> Io:
>
> list(dog,cat,cow) foreach(i,a,a squeak)
> list(dog,cat,cow) foreach(i,a,
>   a say("I'm the " .. (i asString) .. "-th animal")
> )

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 numbers

> Note 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?  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. :-))

> Csaba
-- 
Christian Neukirchen  <chneukirchen / gmail.com>  http://chneukirchen.org