Re: Possible constant assignment operators ":=&quo t; and "::=&qu ot; for Python
Edward Elliott wrote:[color=blue]
> Michele Simionato wrote:[color=green]
> > Python solution is to rely on the intelligence of programmers. If they
> > see an all caps name and then they try to change it without knowing what
> > they are doing, then they are stupid. If you have stupid programmers there
> > is no way the language can stop them for making disasters.[/color]
>
> Which doesn't apply here, one of the OP's examples further up this thread
> doesn't modify any ALL CAPS vars directly:
>[color=green][color=darkred]
> >>> A = [] # let's declare a "constant" here
> >>> b = A # and let's assign the constant here
> >>> b.append('1') # OOPS![/color][/color][/color]
But it makes no sense to use a mutable object for a constant!
The user should use a tuple, or a custom list-like type where
all methods with side effects are removed, so it effectively acts
as a tuple.
Michele Simionato
Edward Elliott wrote:[color=blue]
> Michele Simionato wrote:[color=green]
> > Python solution is to rely on the intelligence of programmers. If they
> > see an all caps name and then they try to change it without knowing what
> > they are doing, then they are stupid. If you have stupid programmers there
> > is no way the language can stop them for making disasters.[/color]
>
> Which doesn't apply here, one of the OP's examples further up this thread
> doesn't modify any ALL CAPS vars directly:
>[color=green][color=darkred]
> >>> A = [] # let's declare a "constant" here
> >>> b = A # and let's assign the constant here
> >>> b.append('1') # OOPS![/color][/color][/color]
But it makes no sense to use a mutable object for a constant!
The user should use a tuple, or a custom list-like type where
all methods with side effects are removed, so it effectively acts
as a tuple.
Michele Simionato
Comment