Accessing variables through sending messages

Alexandre Bergel bergel at iam.unibe.ch
Tue Jun 21 19:14:37 UTC 2005


Sorry to not have given more information about what I try to achieve.
I have been working on adding state to traits. The idea is that the offset for a variable is not constant anymore. For instance, let's assume the following:

T1 defines v1			"offset of v1 = 1"
T2 defines v2			"offset of v2 = 1"
T3 uses T2 + T1 		"offset of v2 = 1 and v1 = 2"

Currently I use the instVarName to access variable (note that I prefixed them like T1.v1). I have a running implementation, but accessing variable in this way is quite slow (about 1000 times slower).

> Do you really need the message send or just the "name" instead of  
> offset? These are two different things... the offset is needed for e.g.
> Traits with state, but sends only for stuff like persistance.

Actually I need to access variables through their names. However their offset is not constant (cf my previous example)

> Of course, this is slow. So if you just want to late-bind the name to  
> the offset, then it would be faster to have bytecode for
> accessing instVars by name. This would be slower than doing offsets,  
> but nevertheless much faster then sends, as no
> lookup needs to be done, no method needs to be executed.

Ok, therefore having a new byte-code would make this solution usuable. I guess this is the way adopted by Self...

Thanks to all of you!
Alexandre

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.iam.unibe.ch/~bergel  
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




More information about the Squeak-dev mailing list