Question 1:
How would other languages get multiple return values from a Perl
procedure? How would code in that other language signal scalar vs list
context? what about the finer subdivisions of Perl context?
Question 2:
How would other languages call a Ruby procedure that expects something in
the proc-slot ? For example, if I have the following code:
def each_recursively(&foo)
each {|x|
foo.call x
x.each_recursively(&foo)
}
end
In Perl I would write code similar to the above:
sub each_recursively{ my($self,$foo)=@_;
$self->each(sub{ my($x)=@_;
$foo->($x);
$x->each_recursively($foo);
});
}
But this is not completely equivalent code, because here $foo is arg
number 1, which would be arg number 0 in Ruby; but in "&foo", the & means
it's the proc-slot (or "iterator"), which is out-of-band and so has no
numbered position in the argument list: it's the absolute-last argument;
it allows for rest-arguments while still allowing a proc to be passed (and
without having to pop the proc explicitly... etc)
so I thought that while a normal call would be like:
$receiver->$selector($arg0,$arg1,$arg2,...,$argN);
a Perl-to-Ruby call could be done like this:
$receiver->call_with_iter($selector,[$arg0,$arg1,$arg2,...,$argN],$proc);
or:
$receiver->call_with_iter($selector,$proc,$arg0,$arg1,$arg2,...,$argN);
or:
$receiver->call_with_iter($selector,$arg0,$arg1,$arg2,...,$argN,$proc);
or:
call_with_iter(sub {
$receiver->$selector($arg0,$arg1,$arg2,...,$argN);
}, $proc);
so... what do you think?
matju