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 {
                print "$a is located at position ${a:n}\n";
        };

The only response I received after suggesting it was that the
attribute might be better called ":i" for index.

By tieing the count accessor to the particular variable, problems
with scope in nested loops quite disappear.

The attribute also becomes available in "lazy arrays" and other
functions trying to pass themselves off as arrays, syntactically.


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 is write a summary, get some consensus and redraft
> the RFC. I'll do this in the next few days.
> 
> 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 in the body of the for/each loop: a clean
>         solution but requires a new or reused function.
> 
> If you really wish to split part of this out into a separate RFC it would
> be best to wait until this one is more finalised.
> 
> John McNamara
> --
> "The Mosaic code has replaced the law of the jungle."
>                                 James Joyce - Ulysses

-- 
                          David Nicol 816.235.1187 [EMAIL PROTECTED]
                                               Yum, sidewalk eggs!

Reply via email to