On Wed, May 29, 2019 at 2:57 PM Ricky Teachey email@example.com wrote:
class HDL: """Every new member of this namespace has signal behavior""" def __setattr__(self, attr, value):
# note: if attr existed already, # SignalBehavior.__set__ was called # add attr as signal behavior setattr(type(self), attr, SignalBehavior()) # SignalBehavior.__set__ will now be called setattr(self, attr, value)
This doesn't seem to work, the first time you setattr on hdlns.x, it will recursively doing so due to setattr(self, attr, value). I do understand you need override __setattr__() to provide an on demand signal creation, and you do need to call setattr() again to actually activate the descriptor, so stack eventually overflows.
With a bit modification it can work, e.g. the last setattr(self, attr, value) should explicitly invoke SignalBehavior().__set__() instead.