about sort and dictionary
Alex Martelli
aleax at mail.comcast.net
Wed Nov 23 22:11:53 EST 2005
Neil Hodgson <nyamatongwe+thunder at gmail.com> wrote:
> Magnus Lycka:
>
> > Except when it isn't obvious. What constitutes mutation of an object?
> > C++ handles this with 'const', and lets the programmer cheat by using
> > transient member variables, since there are cases when you actually
> > want to mutate objects a little, but claim that you don't...
>
> Ruby uses '!' not for mutation but to indicate surprising or
> destructive mutation. If it was placed on all mutators, code would be
> full of '!'s. '!' is less common on methods that modify the receiver
> than on methods that mutate other arguments.
Thanks for the clarification! Unfortunately, this variation on the
convention does make it substantially less clear/sharp/well-defined, and
therefore less useful; whenever I call a mutator I must memorize or work
out (or guess) whether the author considered its mutation "surprising or
destructive" to know whether I need to append a bang or not, which is
peeving; so, I'm now happily reconciled to Python never adopting this.
Alex
More information about the Python-list
mailing list