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/2010-July/101316.html below:

[Python-Dev] Can Python implementations reject semantically invalid expressions?

[Python-Dev] Can Python implementations reject semantically invalid expressions?Nick Coghlan ncoghlan at gmail.com
Fri Jul 2 13:47:18 CEST 2010
On Fri, Jul 2, 2010 at 4:55 PM, Craig Citro <craigcitro at gmail.com> wrote:
> Honestly, though, I'd come down on the side of letting the compiler
> raise an error -- while I understand that it means you have
> *different* behavior, I think it's *preferable* behavior.

But you would be taking a module that will compile and making it uncompilable.

The Python code:

  def f():
    return 1 + "1"

has fully defined runtime semantics: when f() is called, it will raise
TypeError. A module containing this code is still perfectly valid
Python (e.g. the Python test suite does that kind of thing a lot in
tests of the core interpreter semantics).

A Python implementation issuing a SyntaxWarning over this would be
fine, but triggering a SyntaxError would not be valid. However, I'd be
inclined to leave this kind of check to tools like pychecker and
pylint.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
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