On Jun 13, 2008, at 11:48 AM, nathan binkert wrote:

>> Are instances of class objects uniquely identifiable and usable as  
>> keys?
> Only if they provide a __hash__ function, but in theory it should be  
> possible.
>
>> If so, you could use the class as a key using the same mechanism  
>> instead
>> of the string name with Param.blah. So then you use class Foo to  
>> look up
>> a param description rather than actually doing something fancy with  
>> Foo
>> itself. I don't quite follow the subtleties of what you guys are  
>> talking
>> about so I'm not sure if that helps.
> The problem is that we can now do this:
>
> class Foo(SimObject):
>    bar = Param.Bar(....)
>
> class Bar(SimObject):
>    foo = Param.Foo(....)
>
>
> Because of tricks we did with attribute lookup with Param, the
> parameter type isn't looked up until the objects are all constructed.
> In your case:
>
> class Foo(SimObject):
>    bar = Param(Bar, ....)
>
> class Bar(SimObject):
>    foo = Param(Foo, ....)
>
>
> The "bar" parameter would get an error because Bar is not yet defined.
> It's not particularly easy to get around this.  Python 3.0 and the
> new way they do metaclasses can help you solve the problem, but
> unfortunately, that's not going to be mainstream for a while
Where do we have circular references? You can't construct objects with  
circular references in C++, so why do we need it in Python?

Ali
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to