Python's "only one way to do it" philosophy isn't good?
anamax at earthlink.net
Thu Jun 28 17:32:01 CEST 2007
On Jun 27, 11:41 pm, John Nagle <n... at animats.com> wrote:
> One right answer would be a pure reference counted system where
> loops are outright errors, and you must use weak pointers for backpointers.
> ... The general
> idea is that pointers toward the leaves of trees should be strong
> pointers, and pointers toward the root should be weak pointers.
While I agree that weak pointers are good and can not be an
afterthought, I've written code where "back" changed dynamically, and
I'm pretty sure that Nagle has as well.
Many programs with circular lists have an outside pointer to the
current element, but the current element changes. All of the links
implementing the list have to be strong enough to keep all of the list
Yes, one can implement a circular list as a vector with a current
index, but that has space and/or time consequences. It's unclear that
that approach generalizes for more complicated structures. (You can't
just pull all of the links out into such lists.)
In short, while disallowing loops with strong pointers is "a" right
answer, it isn't always a right answer, so it can't be the only
More information about the Python-list