[PEAK] Intended behavior of StructuralFeature._setup ?

Phillip J. Eby pje at telecommunity.com
Tue Feb 24 20:32:00 EST 2004


At 12:54 AM 2/24/04 -0500, Bob Ippolito wrote:
>         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?

Yes, it is.  What's baffling is that I could've sworn I fixed it like a 
year ago.  Guess I'll have to fix it again.


>Also, what's the point of making a tuple of a map that you're just going 
>to iterate over?

'_setup()' is used for initializing unchangeable features, so the value of 
the feature is made to be a tuple.  The 'map' is just there to ensure that 
each item is normalized before being passed to the link notification.


>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 :)

I was keeping the code simple by not writing an extra case, that's all.




More information about the PEAK mailing list