[ruby-talk:02394] Re: Iterator into array

From: Clemens Hintze <c.hintze@...>
Date: 2000-04-08 09:33:00 UTC
List: ruby-talk #2394
Dave Thomas writes:
> Clemens Hintze <c.hintze@gmx.net> writes:

...

> In another post, I suggested a disambiguation in the calling
> syntax to make this possible without breaking other code.

Is this the post with the method* proposal? Excuse me, but I do not
like this. I think we get too much $%&*! into Ruby. Imagine following
would be possible then:

   method* *arglist &block

densed written:

   method**arglist&block

<shudder> ...

I really think we should make shuch things explicite. A small function
like my proposed collectIteratorArgs would do what you want, and would
make clear what happens here. I would question whether the count of
people using such a feature is high enough to make necessary to
introduce a new syntax for it?!?

BTW: I would modify my collectIteratorArgs proposal to:

   def collectIteratorArgs(mid, *args)
     res = Array.new
     mid = method(mid.id2name) if mid.is_a? Symbol
     ret = mid.call(*args) { | *n | res += n }
     return res, ret
   end

Now you would also get back the return value of the method.

> Anyway, ny initial post was the question: is there a neat, functional
> way to collect the values yielded by an iterator, and it seems like
> the answer is (sadly) no.

It seems so, at least I do not know any. And *the* CREATOR has also
not proposed any, though. ;-)

> Regards
> 
> 
> Dave

\cle

-- 
Clemens Hintze  mailto: c.hintze@gmx.net

In This Thread