Newsgroups: comp.lang.smalltalk
Path: utzoo!utgpu!cunews!ags
From: ags@scs.carleton.ca (Alexander G. M. Smith)
Subject: Re: Distributing Objects in Smalltalk-80 r4.0
Message-ID: <1991Jun10.145406.15865@cunews.carleton.ca>
Sender: news@cunews.carleton.ca
Organization: School of Computer Science, Carleton University, Ottawa, Canada
References: <METZGER.91Jun10144221@t500m0.ira.uka.de>
Date: Mon, 10 Jun 1991 14:54:06 GMT

In article <METZGER.91Jun10144221@t500m0.ira.uka.de> metzger@t500m0.ira.uka.de (Metzger Rolf) writes:
>... But I have some problems with the access of the
>objects on the remote machine and the management of errors
>occuring during the execution on the remote machine. Maybe,
>anyone can help me. My questions are:
>
>1.) How can I access the objects on the remote machine ? I
>    am working so far only with global objects, which I can
>    access by their name in the Smalltalk-Dictionary. In the
>    literature above they managed it with the Object-Pointer,
>    but in Smalltalk-80 v4.0 this pointer is not unique. 
>    Is there anywhere an Object-Table, where every object
>    is listed, or what can I do ?

You can fake oop numbers by making a dictionary associating a locally unique
integer with every exported object.  Every time a value is sent out (usually
as the return value of some method invocation from a remote computer, but
also could be as arguments to a method call), you'll have to look up the
value in the dictionary (use an IdentityDictionary) and send its fake oop +
machine address.  If it's not in the dictionary, add it with the next
available free fake oop number.  For garbage collection reasons, a structure
like this dictionary probably already exists. 

As for errors on the remote machine, c'est la vie!  There doesn't seem to be
much that you can do since a debugger is opened on the object with an error,
thus on the machine with that object.  You could change error: or whatever to
open a window on your machine, wherever you are. 

>2.) To save a complex object structure, I have the BOSS
>    (Binary Object Streaming Service) of the Advanced 
>    Programming Toolkit. I have some problems to use it
>    with an ExternalConnection and a ReadAppendStream.
>    Does anyone have an example for me, how to communicate
>    on Unix-Sockets and ReadAppendStreams with BOSS ?

Sorry, I can't help you there.  In my implementation (on Macs using PP 2.3
and AppleTalk) only simple objects are sent over the network (the kind where
object copy == object), using some C primitives to encode them.  Everything
else is sent as a proxy. 

>3.) When I have ProxyObjects using the 'does-not-understand'
>    message to forward the message to the remote machine, I
>    have to overwrite some of the messages of class Object.
>    But some messages as class and basicSize etc. may not be
>    overwritten, says the documentation of the system. But e.g. 
>    to inspect a remote object, I have to overwrite such messages.
>    But when I overwrite e.g. basicSize, I think the 
>    MemoryManagement will not work correct, because space is
>    allocated for the size of the object on the remote machine
>    and not for the size of the Proxy-Object..
>    What can I do here, and which messages must be overwritten ?

The trick is to set the superclass to nil (write a class method in
ProxyObject to stuff the superclass variable with nil).  That makes
everything (except == which is compiled in-line) go to the doesnotunderstand
method.  I also had to copy over one primitive method so that allInstances
would work when looking for all proxy objects.  True, basicSize and all those
methods get sent over to the real object for evaluation.  But then that's
what you want in a real proxy.  The garbage collector doesn't use basicSize
method to find the object size (probably class is hidden in the object record
and used directly). 

- Alex
