A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-September/056704.html below:

[Python-Dev] Visibility scope for "for/while/if" statements

[Python-Dev] Visibility scope for "for/while/if" statements [Python-Dev] Visibility scope for "for/while/if" statementsJosiah Carlson jcarlson at uci.edu
Thu Sep 22 22:58:08 CEST 2005
Alexander Myodov <maa_public at sinn.ru> wrote:

> >> "for (int i = 0; i < 10; i++)" works fine nowadays.
> JC> I'm sorry, but you are wrong.  The C99 spec states that you must define
> JC> the type of i before using it in the loop.  Maybe you are thinking of
> JC> C++, which allows such things.
> "gcc -std=c99" compiles the line "for (int i = 0; i <= 5; i++);"
> perfectly. Along with another sample mentioned above   .
> To this day, I relied upon gcc in terms of standards compatibility...

I misread the error message from my compiler.  It /only/ works in C99
mode.  Previous C standards (which CPython itself conforms to) did not
allow such things.

Interestingly enough, not all C++ compilers (Microsoft) hid variables
created in for loops
(http://www.devx.com/cplus/10MinuteSolution/28908/0/page/2).

 - Josiah

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4