develooper Front page | perl.perl5.porters | Postings from May 2016

Re: [perl #127463] third part of C-style for has messed up scoping

Thread Previous
From:
Aristotle Pagaltzis
Date:
May 27, 2016 11:18
Subject:
Re: [perl #127463] third part of C-style for has messed up scoping
Message ID:
20160527111841.GB22309@plasmasturm.org
* l.mai@web.de via RT <perlbug-followup@perl.org> [2016-02-05 12:00]:
> Am Do 04. Feb 2016, 23:29:24, hmbrand schrieb:
> > Normally, the part inside the parens scopes to the block connected,
> > so this does not surprise me.
>
> The difference is that
>
>   for (A; B; C) { D }
>
> should be equivalent to
>
>   A; while (B) { D } continue { C }
>
> C is executed after A, B, and D. That's why it's surprising that the
> loop body D can see and access variables declared in C, even though
> their definitions haven't even been executed yet.

Variables declared in the A part of for(A;B;C) do not remain declared
past the loop. If you are serious about strict textual equivalence of
these constructs then that must also bother you. Does it?

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About