I was wondering why python doesn't contain a way to make things "const"?

If it were possible to "declare" variables at the time they are bound to 
objects that they should not allow modification of the object, then we would 
have a concept _orthogonal_ to data types themselves and, as a by-product, a 
way to declare tuples as constant lists.

So this could look like this:

     const l = [1, 2, 3]

     def foo( const l ): ...

and also

     const d = { "1" : 1, "2" : 2, ... }

etc.

It seems to me that implementing that feature would be fairly easy.
All that would be needed is a flag with each variable.

Just my tupence,
Gabriel.


-- 
/-----------------------------------------------------------------------\
| Any intelligent fool can make things bigger, more complex,            |
| or more violent. It takes a touch of genius - and a lot of courage -  |
| to move in the opposite direction.                         (Einstein) |
\-----------------------------------------------------------------------/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to