[PEAK] Intended behavior of StructuralFeature._setup ?

Bob Ippolito bob at redivi.com
Tue Feb 24 00:54:03 EST 2004


I'm still studying StructuralFeature here to try and figure out how 
best to add support for mappings (first as a subclass in my own code, 
then perhaps as a patch)...

Right now I'm staring at the code for _setup, and it doesn't seem to 
make a lot of sense:

...
         if feature.isMany:
             p = 0
             value = tuple(map(normalize,value))

             for v in value:
                 doLink(element,value,p)
                 p+=1

note especially the doLink that uses "value" and not "v".  I assume 
this is a bug?

Also, what's the point of making a tuple of a map that you're just 
going to iterate over?  Without using gc.get_referrers or similar "fun" 
code, I can't imagine what could possibly change that list during 
iteration.

FWIW, I decided to make a separate implementation of unlink for 
mappings that are or are not ordered (isMany uses the same 
implementation).  I can't imagine what kind of invariant you're trying 
to preserve in a collection that's marked as unordered by deleting it 
in reverse arbitrary order :)

-bob




More information about the PEAK mailing list