I understand the proposal. I’m just trying to help examine any areas it may
fail in, to make it more robust.
I suppose you could say Enumerables are how you distinguish between zipping
and padding arguments. However, there’s no way to pad with Enumerables, then.
I suppose that might not be a common wish, but there’s that to consider.
Also note that String is Enumerable (enumerates by line), so your example:
(4..6).zip('a', 'b')
Still evaluates to:
[ [4, a, b], [5, nil, nil], [6, nil, nil] ]
And there’s no way to pad with Strings in this scheme.
You noticed this in your reply elsewhere in the thread, and asked for good
ways to separate padding and enumerating values. I just don’t think there
are any intuitive ones. Having variable numbers of arguments that are
semantically different based only on their inheritance hierarchy doesn’t seem
like a good solution to me.
Also, do you say that when argument i is padding, all subsequent arguments i+n
are padding as well? Otherwise all of the following are equivalent:
(4..8).zip(6, 1..2, 5, 2..3)
(4..8).zip(6, 5, 1..2, 2..3)
(4..8).zip(1..2, 6, 5, 2..3)
(4..8).zip(1..2, 2..3, 6, 5)
Which would be confusing. But then, it’s confusing both ways (for me).
Anyhow, I just don’t foresee a solution to this with arguments. The closest I
can come at the moment is this:
(4..8).zip(1..2, 3..5).map { |a, b, c|
[a, (b.nil? ? 'a' : b), (c.nil? ? 'b' : c)]
}
Which is verbose, but it’s clear what is going on (more or less). It could be
helped by a #zip_and_collect method or something (which is a subject for your
other thread :)).
I just don’t think a pure argument solution will get you there. You’re welcome
to prove me wrong, though.
Cheers.
···
On Monday 12 April 2004 5:49 pm, Simon Strandgaard wrote:
Yes, true… I forgot to mention how to distinguish between normal and
padding. If the instance includes the Enumerable module, then normal.
otherwise its a padding argument.
Is it more clear now ?
BTW: How can I make it more clear?