David Steuber on 25 Nov 2003 13:29:36 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Why can't an array element be used as the index var in foreach?


On Tue, Nov 25, 2003 at 04:11:22AM -0500, Mark Dominus wrote:
> Mark Rogaski <wendigo@pobox.com>:
> I think the correct answer to the question is that there's no reason
> in principle why Walt's idea doesn't work, and that it could be made
> to work without much difficulty, but nobody has ever bothered.

I agree with this.  I was rather surprised about the whole thing and
tried it myself.  Perl is emiting a syntax error, not quietly failing.
I tried a couple different variations of the theme but none of them
worked.  Unless the language definition has some strange prohibition in
it, I would call this a bug in Perl.

I even tried the more verbose 'for ($c[0] = 0; $c[0] < 5; $c[0]++)' with
no success.  Perl would have none of it.

-- 
David Steuber           |  telco:610.436.1677
302 E Marshall St       |  http://www.david-steuber.com/
Apt 612                 |  (do ((a 1 b) (b 1 (+ a b)))
West Chester, PA 19380  |      (nil a) (print a))
-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**