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/2000-December/011123.html below:

[Python-Dev] new draft of PEP 227

[Python-Dev] new draft of PEP 227Tim Peters tim.one@home.com
Tue, 19 Dec 2000 00:58:45 -0500
[Tim]
> I expect it would do less harm to introduce a compile-time warning for
> locals that are never referenced (such as the "a" in "set").

[Guido]
> Another warning that would be quite useful (and trap similar cases)
> would be "local variable used before set".

Java elevated that last one to a compile-time error, via its "definite
assignment" rules:  you not only have to make sure a local is bound before
reference, you have to make it *obvious* to the compiler that it's bound
before reference.  I think this is a Good Thing, because with intense
training, people can learn to think like a compiler too <wink>.

Seriously, in several of the cases where gcc warned about "maybe used before
set" in the Python implementation, the warnings were bogus but it was
non-trivial to deduce that.  Such code is very brittle under modification,
and the definite assignment rules make that path to error a non-starter.

Example:

def f(N):
    if N > 0:
        for i in range(N):
            if i == 0:
                j = 42
            else:
                f2(i)
    elif N <= 0:
        j = 24
    return j

It's a Crime Against Humanity to make the code reader *deduce* that j is
always bound by the time "return" is executed.





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