At 6:14 PM +0000 3/12/04, Peter Haworth wrote:
I have some issues with the way attributes are referenced. According to the
PDD:

classoffset Ix, Py, Sz

Returns the offset of the first attribute for class Sz in object Py.

getattribute Px, Py, Iz

   Returns attribute Iz of object Py and puts it in Px. Note that the
   attribute number is an absolute offset.

So, compilers are expected to know the relative offsets of attributes within each class? That's reasonable enough, assuming that attributes are only directly accessed by code whose objects' classes have been declared.

Yes. The assumption is that the compiler is keeping track of the class its building. That seems reasonable, though you may run into issues with classes whose definitions are scattered across multiple independently loaded bytecode files. I'm OK with putting a "Don't *do* that!" in the docs, though. :)


> addattribute Px, Sy

Add attribute Sy to class Px. This will add the attribute slot to all objects of class Px and children of class Px, with a default value of Null.

Should we just try to ensure that any class which wants to add attributes to itself always uses the named version of getattribute?

Nope, not needed. If a class adds an attribute, it always goes on the end of the attribute set for that class. Presumably (a presumption I'm comfortable with) the code doing the adding knows that there are already N attributes, and that its adding attribute N+1 to the list. (I'm assuming the common case will be eval'ing source, in which case the compiler can see the current layout and emit appropriate bytecode for the new number)


 Do we allow code
which modifies other classes' attribute lists? Do we need to mark classes
as numeric/named attribute access, and restrict addattribute's use to
classes which use named attributes?

No (sorta) and no, respectively. Removing a used attribute strikes me as a Bad Thing, and I can't think of a reason to do it that shouldn't result in horrible flaming death and bizarre behaviour. And adding attributes, since they always go on the end of a class' list of attributes, is harmless.


As well as involving much finding of instances, and moving of their attribute
values, this isn't thread safe (please excuse my lack of PASM syntax
knowledge):

Yeah, adding an attribute requires a stop-the-world action, as every object that has the modified class needs to be modified. That's a non-trivial activity.
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to