Are you bound to exactly this structure?
If you can define the structure, you can use a nested structure that uses pointers instead of values:

NBTestNestedStructure2>>
fieldsDesc

������ ^ #(
������ ������ NBTestStructure1byte* oneByte;
������ ������ int otherField
������ ������ )
��
Now you can create and access the innerstructure like this

myStruct := (NBTestNestedStructure2 new oneByte: (NBTestStructure1byte externalNew field: 1)).
myStruct oneByte field. " -> 1 "
myStruct oneByte field: 4.
myStruct oneByte field. " -> 4 "

Well I'm not bound to anything really, but what you did here seems nice and should do the trick for me.
Initially i just got rid of the second struct and incorporated each element of the second struct inside the first one. I guess if the size they take in memory is the same it should work too.
But I'll use your solution cause it looks nicer :)

Whereas I don't know if the external memory is freed.

From what is written in NBExternalStructure it probably isn't but I'll just have to remember to do so.


On the other hand, I am curious about the internal mechanisms here.

yes, self struct2 will create a copy of the struct2 and any change to struct2 value only applies to this copy.

If "self struct2" returns a copy it means that even if it is not a struct and simply an int it also returns me a copy right ?
However, when you call "self struct2: ..." or "self otherField: ..." it actually modifies the object itself.
So why doesn't it let me access the actual object directly ? If I can modify the whole object why can't I modify just a part of it ? What is the inherent issue ?
��