[comp.sys.mac.programmer] Odd behavior

gary@sun.mcs.clarkson.edu (Gary Levin) (09/06/89)

In article <21813@cup.portal.com> ts@cup.portal.com (Tim W Smith) writes:

tim>Date: 3 Sep 89 02:57:30 GMT
tim>The method dispatching is different when you run the program from
tim>Think C that it is when you build an application.  When you run
tim>from Think C it does not appear to optimize method dispatching.  I
tim>noticed this because I wanted to see how much overhead was
tim>involved in OO stuff in Think C, so I wrote a test program and
tim>single stepped it with TMON.  Everything wemt through the method
tim>dispatcher.  I then build the application and single stepped.  Now
tim>many things did not go through the method dispatcher.  Instead
tim>they jsr'ed to a jmp to the method.

This sounds like it might possibly answer why the source for the class
libraries was included in the sample programs instead of using
libraries/projects.  It also might explain why my program runs
correctly from inside THINK-C, but not when I double click it as an
application.  

(1) Is it in advisable to build libraries/projects that hold the Class
library routines?

* I think a light bulb just went off.  Monomorphic methods are handled
* as subroutine calls.  There is no way that you can combine separate
* modules because they won't use the right dispatch method, because you
* can't recognize that a method was overridden.
* Confirmation?

(2) One is not supposed to distribute the Class library source, either
original or modified.  

One is advised to base programs on Starter or Pedestal.  May we
distribute modified source of those routines (just the ones in the
folder, not the Class library routines that are included)?

May we distribute modifications of TinyEdit?

--
Gary Levin/Dept of Math & CS/Clarkson Univ/Potsdam, NY 13676/(315) 268-2384
BitNet: gary@clutx   Internet: gary@clutx.clarkson.edu

lsr@Apple.COM (Larry Rosenstein) (09/07/89)

In article <GARY.89Sep5171125@milo.clarkson.edu> gary@sun.mcs.clarkson.edu 
(Gary Levin) writes:
> This sounds like it might possibly answer why the source for the class
> libraries was included in the sample programs instead of using
[referring to changing method calls to direct JSRs]

In MPW the conversion of method calls to direct JSRs is done in the 
linker, because it requires knowledge of all the methods in the 
application.  The output from the compiler is exactly the same whether the 
optimization is done or not.  As you said, the advantage to doing this is 
that you can distribute libraries without requiring that people use one 
dispatching scheme or another.  

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1