views:

86

answers:

1

I plan about implementing a dynamic linking into my smalltalk dialect. The problem is about getting message passing to work with dynamic linking.

Message passing itself is as simple as this: message with a selector is sent to the object, the object picks up a method matching with the selector from it's protocol, it then process the data bundled with the message and returns a result.

In image-based implementations, one can implement message passing in very straightforward manner - Your message selectors can be just integers translated from the global symbol table, your protocols can be just hash tables with integers and addresses in them. Assuming it's all compiled into an one big image with that global symbol table.

In dynamic linking, you can't assume a symbol table pointing to a correct selector. You can turn around the problem with using strings as your selectors, but you doom the language being slower.

There's one way, and it involves copying the protocols and a table of selectors for the process to relocate them properly. But it's sounds like a quite lot of work.

Is there better ways to solve this problem? Also, is the dynamic linking worth it? How could I implement the relocation for the selectors and protocols?

+1  A: 

Sure you can assume a global symbol table, you just have to update it and ensure at link time that the codes only uses symbol instances from that table. Did you have a look at Squeak? The loading code is image-level (not VM) so it's easy to browse from any Squeak image.

Damien Pollet