Reading in a project problem

Ned Konz ned at squeakland.org
Mon Jul 12 00:54:23 UTC 2004


On Sunday 11 July 2004 1:47 pm, Brad Fuller wrote:
> > > "Reading an instance of <class>. Which modern class should it
> > > translate to?"
> > >
> > > With the following selections
> > > 	Let me type the name now
> > > 	Let me think about it
> > > 	Let me find a conversion file on the disk.
>
> Thanks for the questions Ned!
>
> > Does the class that is reported exist in the image?
>
> No, the class(es) that are reported do not exist in the image. Not on any
> of the machines.

That's the problem. The project file contains a serialized version of the 
interesting objects in the project. But it doesn't contain classes or method 
definitions, unless you explicitly choose to store the change set with the 
project (and unless the change set has all of the required definitions).

So a reference to a class is instead stored in a .pr file as something that, 
when de-serialized, is equivalent to:

	DiskProxy global: #YourClass selector: #yourself args: #()

and then is resolved by looking in the Smalltalk dictionary under #YourClass.

But of course YourClass doesn't exist, and so Squeak offers to let you either:

	- load a change set that might include conversion methods
	- say that instances of YourClass should really become instances of 
SomeOtherClass
	- stop loading

Look at implementors of #objectForDataStream: to find more special cases like 
this.

If you want to distribute projects *and* your own code, the easiest way to do 
it is either to:
	* ensure that all the class and method definitions you need are in the 
project's change set (you can use the Dual Change Sorter to copy methods from 
other change sets, as necessary), or
	* package the .pr and the appropriate Smalltalk code (.cs, .mcz, .st, etc.) 
inside a SAR file (a zip file that Squeak knows how to load).

> I clearly need to know more about "projects". Can
> you point me in a direction of documentation?

What I do usually is either or both of:

	- read the code (look here for SmartRefStream/ReferenceStream, DiskProxy, and 
methods like objectForDataStream: and the "file in/out" and "objects from 
disk" method categories)

	- poke around on the Squeak Swiki.
		http://minnow.cc.gatech.edu/squeak/1817
		http://minnow.cc.gatech.edu/squeak/2318

	- do some Googling

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list