[Tutor] (OT) Flame wars

Alan Gauld alan.gauld at btinternet.com
Mon Nov 6 23:52:05 CET 2006


"Danny Yoo" <dyoo at hkn.eecs.berkeley.edu> wrote
> So let's try to squash this one now.  There are more interesting 
> problems
> to solve.  Or other flame wars to fight.

I wasn't aware we were having a war, but I'm happy to desist :-)

> Let me see if we can do something constructive.  I've been doing a
> shallow, superficial study of the Ruby language at the moment.  One 
> of the
> things I've been impressed about is that they've managed to make 
> lambdas
> look non-threatening to people with their syntactic sugar of "code
> blocks".

Ruby blocks are almost as good as Smalltalk blocks for this
kind of thing and very powerful. Regular readers will know I have
often expressed dissappointment at the limitations of Python's
lambdas, it's one thing the Ruby boys have got right IMHO.

> The exact functionality can be done in Python, but it does look a 
> little
> more intimidating at first:
>
>     ## Python
>     def twice(f):
>         f()
>         f()
>     twice(lambda: sys.stdout.write("hello world\n"))
>
> This does the same thing, but it looks a little scarier because the
> concepts needed to grasp his are superficially harder than that in 
> the
> Ruby code.

The other advantage in Ruby is that the block can be arbitrarily
complex, not just a single expression as in a Python lambda. This
allows us to embed loops and all sorts, effectively adding new
command structures to the language in a way that only Lisp
and Tcl have really been good at up till now.

Alan G. 




More information about the Tutor mailing list