Type Inference

Joshua Gargus schwa at cc.gatech.edu
Wed Sep 13 19:06:42 UTC 2000


Edward P Luwish <eluwish at uswest.com> wrote:
> Type inference is non-trivial, even though your need to see what messages can be
> sent to a variable seems like a small subset of the entire problem.  Obviously,
> if you know the class of the variable (a big if!) the set of messages is derived
> by travelling up and down the inheritance path.
> 
> The source of the difficulty is the inability to know (until run time) the class
> of the object RETURNED by a message send.  So, when (later on in the method) a
> message is sent to that object, you (the static analyzer, not the Smalltalk
> system!) have no way of knowing which class's method actually responds to that
> message.
> 

It depends whether Anthony wants to know which methods are performed, or
which
messages are sent to the variables.  He *says* messages, and if this is
what he means,
then this is a simple case of syntactic analysis with no type inference
whatsoever 
involved.  From the context of his question, is seems as though this
might be all that
is necessary.  Clarification, Anthony?

Joshua

> In the method under examination, let's send printOn: to an object returned by an
> at: to some array.  Since each element of an array can be an object of a
> different class, which printOn: method will be executed?  The beauty of Smalltalk
> is that you don't have to know.  The frustration of Smalltalk is that you can't
> know, which implies that it's a lot easier to port TO rather than FROM
> Smalltalk.  The C Translator classes in Squeak make a lot of assumptions about
> the Smalltalk code they consume - the interpreter classes have to be written in a
> very specialized Smalltalk subset ("Slang").  You should be able to port the
> *interpreter* (i.e., the VM) to Thor, but it would still be interpreting
> Smalltalk.
> 
> I haven't followed Lex's work - although I don't need type inference like you do,
> I'm curious about how he got around the issues.
> 
> ajh18 at cornell.edu wrote:
> 
> > Hello all,
> > Is anyone else working on type inference besides Lex Spoon with his Lucid
> > system?  I just want to be able to look ahead and see what messages get
> > sent to a variable.  I need this so I can try to translate Smalltalk to
> > Theta which requires variables and methods to be typed.  A Theta type,
> > like an interface, specifies what messages an object must understand.  If
> > I can build this translator I will be able to port Squeak to Thor, a
> > distributed object database system from MIT.  For more information see
> > the Squeak-Thor page on the swiki at http://minnow.cc.gatech.edu/squeak/1643.
> > Thanks,
> > Anthony





More information about the Squeak-dev mailing list