Useless expressions [was Re: Undefined behaviour in C]
Terry Reedy
tjreedy at udel.edu
Mon Mar 28 15:34:59 EDT 2016
On 3/27/2016 9:26 PM, Steven D'Aprano wrote:
> On Mon, 28 Mar 2016 03:39 am, Terry Reedy wrote:
>> So Bart is proposing
whether 'actually' or 'hypothetically'
> I don't think Bart is intending this as an actual proposal to change Python
> so much as just a hypothetical to discuss.
I don't remember Bart saying anything of the sort. I'll let him clarify
hit meaning.
>> to either disable an extremely useful feature or
>> split Python into two slightly different dialects. I think both are bad
>> ideas.
>
> I don't think that's quite fair.
I don't think your strained nitpicking of my statement is quite fair. It
is definitely faulty.
> The interactive interpreter is already
> slightly different from non-interactive use,
Yes, the extra behavior of interactive mode is specified in the
Reference in the section on Expression statements.
https://docs.python.org/3/reference/simple_stmts.html#expression-statements
But as far as I can remember, both run the *SAME PYTHON LANGUAGE*.
Dialects are a property of languages, not of interpreter modes.
> in that bare expressions print the result,
Expressions evaluate to objects. Having the interpreter also display
the object is at most an added semantic. It is not a syntax difference
and in that sense is not a *language* difference*.
> while in non-interactive use they just get garbage collected.
Garbage collection is not relevant to this proposal or discussion.
AFAIK, Objects become eligible for garbage collection at the same time
in either mode.
> It wouldn't be that different to change "print versus ignore" into "print
> versus raise error".
Are you serious? Having the *same code* execute in one mode and raise
in another, and thereby abort execution of all following code, is quite
different. It makes the set of legal statements different and that is
the basic definition of a language. It suite fair to call the different
sets of legal statements 'slightly different dialects'.
> I think it is a bit extreme to call that two different
> dialects.
Your nitpicking is what is extreme.
> If so, then the current interactive interpreter is also a
> different dialect.
To repeat, the current interactive interpreter runs the same sequence of
statements, which is to say, the same language. It just outputs extra
information about what is going on. CPython debug builds display even
more extra information (about references).
>>> 0
0
[44187 refs]
>>> a=0
[44189 refs]
>>> 0
0
[44189 refs]
This in itself does not mean that the debug interactive interpreter is
yet a third dialect of Python.
--
Terry Jan Reedy
More information about the Python-list
mailing list