On 13/10/2017 15:39, Steve D'Aprano wrote:
On Fri, 13 Oct 2017 11:54 pm, Gregory Ewing wrote:

Neil Cerutti wrote:
I can tell at a glance if a parameter is expected to be
modifiable just by looking at the function signature.

The question is why doesn't anyone feel the need to be
able to do that for Python functions? Whether a function
modifies things passed to it is just as important to
know in Python as it is in C.

Lots of people would like Python to have a "freeze" function that can make
immutable objects, it is a moderately common feature request.

Some people (myself included) would like a "const" declaration that gives us
names that can only be bound to once:

const spam = "NOBODY expects the Spanish Inquisition!!!"  # Okay
spam = "foo"  # Error.

Presumably also:

const def f:
const class c:
const import i


I don't mind if that is a runtime error, although a compile time error would
be nicer.

This would be of most use when the byte-code compiler (assuming there is one) knows about them. But many will be inside imported modules whose contents, AIUI, are not visible to the byte-code compiler.

And then they would be accessed as:

  i.spam

So this would be a const attribute.

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to