[Edu-sig] COUNTER class.
Kirby Urner
urnerk@qwest.net
Wed, 27 Feb 2002 19:47:19 -0800
>
>I couldn't find a way to give this property to assignment. Every time an
>assignment happens with one of these things, I would like to count it.
>Is there a way to do that?
>
>jeff
Trickier I think, because unlike <, > etc., = doesn't
trigger some __xxx__ method. But sticking something
in a property or explicitly invoking a method could
work. If you're willing to do something like:
b.assign(a) or b.value = a
in place of
b = a
then we'd have some options. But that might detract
from the readibility of your sort algorithms, as
there's nothing more natural than plain old =.
So maybe we fall back to triggering an assignment
counter each time there's an assignment, e.g. pepper
the code like:
a = b
a.assign() # not sure if you count one or both
That's not much better than sticking in accumulator
variables, but perhaps keeps things clearner in that
you're still using the elements to be sorted to
keep track of their own manipulations.
Kirby