[comp.sys.mac.programmer] Think C 32K global data l

keith@apple.com@canremote.uucp (keith@Apple.COM) (12/21/89)

From: keith@Apple.COM (Keith Rollin)
Subj: Think C 32K global data limit: workaround?
Orga: Apple Computer Inc, Cupertino, CA

In article <1672@cbnewsk.ATT.COM> ech@cbnewsk.ATT.COM (ned.horvath)
writes: >In article <1664@cbnewsk.ATT.COM> I wrote:
>> So far, the MPW linker won't give non-apps globals, hence no
method  >> dispatch tables.
>
>From article <5837@internal.Apple.COM>, by lsr@Apple.COM (Larry
Rosenstein): >> See Tech Note #256.  
>
>I've seen it.  It's an excellent example of "tell me what you need,
I'll >tell you how to live without it."  The suggestion is incomplete
-- e.g. >initialized data is not addressed -- and requires the
connivance of the >underlying application.  I don't have that
connivance with, say, DAs. >Or other drivers.  Or FKEYs. Or any other
code resource intended to exist >independently of a PARTICULAR
application.  Or even with HyperCard -- the >example in the technote
requires careful attention in the Hypercard script >to making sure
the XCMD-with-persistent-data is properly set up and torn >down -- an
error in that script hoses memory at random, a very user- >unfriendly
XCMD to put in the hands of "the rest of us."

Ned,

One of us - either you or me - doesn't know what you're talking
about. When you say that it doesn't address the issue of initialized
data, what do you mean? After all, MakeA5World is supposed to do this
for you. By "this", I mean that it  creates space for your data, and
initializes it all to zero, or with predefined  values if you are
using C or Assembly.

As for DA's, you don't have to rely on any host application. You can
just stick your A5 reference into dCtlStorgage. Same with other
drivers. As for FKEYs, you can use a hack that I used originally,
which was to link in a little assembly PROC that I jammed my A5
reference into.

If you have other issues with the technote (like, for example, I
forgot to  suggest that one call InitGraf when setting up his/her A5
world), then please let me know. In particular, I'd like to hear your
suggestions on getting rid of the global data without getting some
sort of close message. And remember, you don't HAVE to use persistant
global data. Nothing in the rules about that. I just mentioned it and
showed how to do it in the (inevitable) case that someone asked.

Finally, I'd like to hear where you read "and I'll tell you how to
live without it." I tried to be accomodating. In cases where I said
you couldn't do something, I also tried to explain why. If I failed
in some places please let me know.

All of this applies to EVERY TECHNOTE, and to EVERY READER of this
network: if you have issues with out Technotes...then let us know!
Don't go flaming on the nets. We're here. We listen. These technotes
are for you, and we want them to be useful...

-- 
---------------------------------------------------------------------
--------- Keith Rollin  ---  Apple Computer, Inc.  ---  Developer
Technical Support INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin,
Contusions
---
 * Via MaSNet/HST96/HST144/V32 - UN Mac Programmer
 * Via Usenet Newsgroup comp.sys.mac.programmer

beard@ux1.lbl.gov@canremote.uucp (beard@ux1.lbl.gov) (12/21/89)

From: beard@ux1.lbl.gov (Patrick C Beard)
Subj: Think C 32K global data limit: workaround?
Orga: Lawrence Berkeley Laboratory, Berkeley

In article <37420@apple.Apple.COM> keith@Apple.COM (Keith Rollin)
writes: >Ned,
>
>One of us - either you or me - doesn't know what you're talking
about. When you >say that it doesn't address the issue of initialized
data, what do you mean?  >After all, MakeA5World is supposed to do
this for you. By "this", I mean that  >it creates space for your
data, and initializes it all to zero, or with  >predefined values if
you are using C or Assembly.

This is true.  I've taken the tech note to task by creating
independent code resources written in C++ that have global variables
with initialized data. The ability to stuff objects in a code
resource is really handy, I've written simple interfaces (objects)
for encapsulating the nastiness that goes along with this MakeA5World
stuff and hides it from me.

>If you have other issues with the technote (like, for example, I
forgot to  >suggest that one call InitGraf when setting up his/her A5
world), then please >let me know.

I've tried calling InitGraf to initialize my code resource's A5
world.  It may have been that something else was making it crash, but
is this a valid thing to do so that the A5 world will have properly
initialized quickdraw variables?  I've been stuffing values into the
qd globals and it works.

>Finally, I'd like to hear where you read "and I'll tell you how to
live >without it." I tried to be accomodating. In cases where I said
you couldn't do >something, I also tried to explain why. If I failed
in some places please let >me know.

What I want to know is when you will tell us how to create jump
tables for our multi-segmented code resources.  THINK C lets us do
that.  Take us one step closer to the capabilities they provide and
the MPW languages will become a viable development environment for
non-application code.

Why?  I want virtual functions in my code resources!  Why must they be
implemented (for C++ or Object Pascal) as jump table entries?  I
don't see why the method tables can't be resolved at data
initialization time.  It's easy to write code that computes the
absolute addresses of methods and stuffs it into a table of function
pointers.

Thanks for global data, now give me jump tables!  Then, rewrite MacApp
in C++, then..., well I can dream.


---------------------------------------------------------------------
---------- -  Patrick Beard, Macintosh Programmer                    
   (beard@lbl.gov) - -  Berkeley Systems, Inc.  ".......<dead
air>.......Good day!" - Paul Harvey  -
---------------------------------------------------------------------
----------
---
 * Via MaSNet/HST96/HST144/V32 - UN Mac Programmer
 * Via Usenet Newsgroup comp.sys.mac.programmer