[PEAK] Re: trellis.Set.discard

Phillip J. Eby pje at telecommunity.com
Tue Oct 21 21:22:37 EDT 2008

At 08:50 PM 10/21/2008 -0400, Phillip J. Eby wrote:
>Hm.  ISTM that this is a bug in Component creation, in that it 
>should push and restore read-onlyness.  The make() should be 
>idempotent with respect to the @compute rule.

Unfortunately, it's not *quite* that simple.  What's really needed is 
to allow changes to cells even during "read-only" periods, as long as 
they are "new".

It's the precise definition of "new" that eludes me...  I suppose we 
could keep a set of "cells created" within a given "transaction", and 
clear it upon commit.  Component creation could then push and pop 
this set, instead of pushing and popping read-onlyness.

Unfortunately, such a set could complicate garbage collection, unless 
it used weak references.  I suppose that's probably an acceptable 
solution, though.

Also, we probably don't want to consider cells created outside of 
Component creation to be "new", so the "cells created" set could 
perhaps be None during the main transaction body.

I'm thinking something like ctrl.new_cell(cell) that either registers 
the cell or does nothing, depending on whether the "cells created" 
set is None or not.  Then changed() would check if the changed cell 
is in the set in the readonly case.

More information about the PEAK mailing list