[comp.sys.apple] initializing APW C data structures

AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") (03/21/89)

>Date:         Tue, 21 Mar 89 07:59:43 GMT
>From:         Scott Lindsey <claris!wombat@AMES.ARC.NASA.GOV>
>Subject:      Re: large GS programs in APW C
>
>[...] I don't know how much non-dynamic space AWGS uses (static is a
>poor term here, because it means something different to C than it
>does to the loader), especially if you add up the 6 modules and all
>the internal stuff.

You're right--I should have clarified what I meant by "static."  I
was referring to the C storage type of that name (as opposed to auto,
extern, and register).  Objects declared outside of functions are
static even if you don't use the word "static" with them (although
whether you use "static" does affect the object's visibility!).
"auto" is the default for objects declared inside functions, and it
means they objects are allocated automatically (on the stack) when
the function is entered.

>What's really bad is that the 6 modules are all (mostly) dynamic.  If
>it were done in C using the 1 data bank scheme, all the non-array
>variables for every module, loaded or not, would have to be loaded
>all the time.  Yes, you can start using a multi-bank scheme, but
>that's where it starts getting messy, especially if you mix in
>assembly code.


>> Does something come out of that 64K that I'm forgetting?
>
>Initialized variables, maybe?  The only thing that goes in ~arrays
>are arrays.  I assume by auto variables you mean auto-initialized
>variables? They go right in ~globals too.

From _C Wizard's Programming Reference_, p. 66:  "All scalar
variables can be initialized when defined.  If the storage class of
the scalar is static, then the initialization occurs only once--
conceptually by the compiler.  In the case of auto and register
storage class scalar variables, the initialization assignment occurs
at each entry to the owning block."

But for initialized structures you have to use static objects in C.
If the GS had resources already, there'd be very little need for
static objects.  (My old boss is working on a large MPW C program for
the Mac with a global variable count of either zero or one--I forget
which.  His data structures are all allocated dynamically and rooted
in the REFCONs of his windows.  Pretty slick, and extremely
weird-looking to read--more levels of indirectio and function calls
by pointers stored in tables than the mind is usually asked to
comprehend.)

>Scott Lindsey     |"Cold and misty morning. I heard a warning borne in the air
>Claris Corp.      |    About an age of power when no one had an hour to spare"
>ames!claris!wombat| DISCLAIMER: These are not the opinions of Claris, Apple,
>wombat@claris.com |    StyleWare, the author, or anyone else living or dead.

 --David A. Lyons              bitnet: awcttypa@uiamvs
   DAL Systems                 CompuServe:  72177,3233
   P.O. Box 287                GEnie mail:    D.LYONS2
   North Liberty, IA 52317     AppleLinkPE: Dave Lyons

wombat@claris.com (Scott Lindsey) (03/22/89)

From article <8903210858.aa20227@SMOKE.BRL.MIL>, by AWCTTYPA@UIAMVS.BITNET ("David A. Lyons"):

> 
> From _C Wizard's Programming Reference_, p. 66:  "All scalar
> variables can be initialized when defined.  If the storage class of
> the scalar is static, then the initialization occurs only once--
> conceptually by the compiler.  In the case of auto and register
> storage class scalar variables, the initialization assignment occurs
> at each entry to the owning block."

Register variables on the GS.  That's a good joke :-)

> But for initialized structures you have to use static objects in C.
> If the GS had resources already, there'd be very little need for
> static objects.  (My old boss is working on a large MPW C program for
> the Mac with a global variable count of either zero or one--I forget
> which.  His data structures are all allocated dynamically and rooted
> in the REFCONs of his windows.  Pretty slick, and extremely
> weird-looking to read--more levels of indirectio and function calls
> by pointers stored in tables than the mind is usually asked to
> comprehend.)

Yeah, if the GS had resources already, that's true.  In AWGS, all document
data is stored off of the RefCon as well.  The overhead, though, for the
6 modules & everything else is respectable, but it could be cut at least
in 1/2 by using resources: WIND's DLOG's ALRT's etc.

I really want C to be a viable development enviroment for the GS.  But I
can't see it happening for at least a year.



-- 
Scott Lindsey     |"Cold and misty morning. I heard a warning borne in the air
Claris Corp.      |    About an age of power when no one had an hour to spare"
ames!claris!wombat| DISCLAIMER: These are not the opinions of Claris, Apple,
wombat@claris.com |    StyleWare, the author, or anyone else living or dead.