Chaim Frenkel wrote:
This is making the index variable into an a wrapper object.
No it isn't. Or at least it doesn't have to.
Often there is a need to find the key an object was found in a container.
More often in hashes than in arrays.
And I think this discussion belongs in -data.
On Tue, Aug 29, 2000 at 05:51:44PM -0500, David L. Nicol wrote:
I'd like to see a last-container-key attribute included as
a possibilty; and that attribute called ":n" to match the
argument of integer functions in introductory algebra. This
approach gives us
for $a @some_list {
John McNamara [EMAIL PROTECTED] writes:
As far as I can see the current consensus is as follows:
1. Implicit variable: nice but not really worth the trouble.
2. Explicit variable between foreach and the array: might conflict
with other proposals.
3. Explicit counter
This is making the index variable into an a wrapper object.
Since the underlying value can't (or shouldn't) know which of the n
containers it is in.
chaim
"JSD" == Jonathan Scott Duff [EMAIL PROTECTED] writes:
JSD Interesting. I must have missed this. I'm not wild about the syntax,
JSD but
On Tue, Aug 29, 2000 at 09:15:35AM +0100, John McNamara wrote:
At 13:11 28/08/00 -0400, Steve Simmons wrote:
To tell the truth, this third item should probably should become
a separate RFC, and if you'd like to simply say one is forthcoming,
that'd be fine by me.
What I really want to do
David L. Nicol writes:
Why not use an explicit perl5 counter?
my $index;
foreach $item (@array){ $index++;
print $item, " is at index ", $index, "\n";
}
Well, one reason is that your example doesn't work (it starts the
index at 1 instead of 0). You'd need to do
I don't see why this should be an implicit counter. This (might)
cause extra work for every foreach loop in every program (depending on
how foreach is implemented).
Why not use an explicit counter instead? Something like
foreach $item $index (@array) {
print $item, " is at index ",