Erik BéČfors <erik / bagfors.nu> writes:

[...]

> Well.  The way blocks and iterators are used in ruby is not like it is
> in perl (I don't know python very well but I don't know of anything like
> that.
> 
> for example:
> myObject.each { |x| puts x }
> 
> How would that code look in perl(6) or python??  The normal way of doing
> it is

it should not be hard in perl6. Already possible in perl5:


sub myeach(&@) {
    my $f = shift;
    $f->($_) foreach @_;
}

myeach { print "$_[0]\n" } @l;

(well, if you accept the not-much-sugar-for-naming-the parameter :)


As for, python, it's much harder since "lambda" only accept expressions, not
statements :-(


[...]

> that code differs alot between the languages.  Ruby uses alot of
> iterators and I don't see how they can be used from other languages.

the main difference here being:
- the non OO syntax
- the "yield" being explicit (replaced by a call)