Howdy,

I have some Smalltalk objects that represent external data and I am looking
for a neat way to access them.

The data that I am dealing with is C binary objects described by DWARF
schemas. So I will load a type declaration like this:

struct outer {
  struct inner {
    int a, b;
  };
};

and then I will want to be able to write convenient expressions like:

aStruct outer inner a + aStruct outer inner b

I have implemented this already but I am not sure that I took the right
approach. I have implemented these accessors like #outer #inner #a #b via a
messageNotUnderstood: method that looks into the object, so that 'aStruct
outer' is equivalent to 'aStruct field: #outer'. My concern is that the
names of the C struct fields can collide with existing Smalltalk methods
and then I will get totally unexpected results.

Is there a canonical solution to this problem?

The first idea I have is to add a bit of syntatic sugar, like to write
'aStruct _outer _inner _a' where the leading underscore avoids method name
collisions and is then stripped off in messageNotUnderstood. That doesn't
seem especially elegant though.

I can't quite bring myself to write verbose things like

((aStruct child: #outer) child: #inner) child: #a

Reply via email to