[comp.sys.atari.st] Personal Pascal question

MCCABE@MTUS5.BITNET (08/23/88)

Date:    22 August 1988, 12:36:14 EST
From:    Jim McCabe                                      MCCABE at MTUS5
To:      INFO-ATARI16 at SCORE.STANFORD.EDU
Subject: Personal Pascal question

This is directed to people who really know a lot about Personal Pascal, or
those who have written huge programs in it.

Today, while rewriting the editor in a BBS of mine, my source code
stopped compiling.  The compiler gets to the last line of the file
("end."), and stops with the error

          Too many external references

So, I looked through my entire Personal Pascal manual for some information
about just what the limit IS for external references, and it doesn't say
anything about them.  Here's my situation:

   I have declared:

          305 constants, plus those in GEMCONST.PAS
                 (I use a very large resource file)
          28 types, plus GEMTYPE.PAS
          97 global variables (I *have* to use them, or else each
                 procedure would have huge parameter lists --
                 believe me on this...) containing:
              6 file variables
              17 dialog box pointers (Dialog_Ptr)
              1 menu pointer (Menu_Ptr)
          8 external functions or procedures, all global
          15 TOS function declarations, all global
          6 pointer variables, all local to one procedure

Now the weird thing is, I have had the 8 EXTERNAL routines and the
15 TOS routines declared for months, and it's always taken them until
today when I changed my editor so that it uses pointers instead of
a big array.  The editor routine even compiles beautifully, and the
error pops up on the last line of the main program.

Has anyone else experienced this error?  What *is* the limit on
external references?  (By the way, I'm using version 1.x, NOT one of
the newer version 2.x compilers...)  I'm going to make the file
variables local, since those use pointers too, but still, the
error doesn't make sense.

I don't think Personal Pascal handles external referrences well
in the first place.  For one thing, when I try to link together
a few really large modules, the compiler always "forgets" to
link a couple of the files (seems random), and it also screws up
some of its own internal variables.  For instance, it will give
me a linking error, saying that the function "bssanf" is undeclared.
My program doesn't use any function bssanf.  :)

Does anyone have any ideas on this?  Maybe the new version of
the compiler works better, who knows.


                                                 Jim McCabe
                                                 MCCABE @ MTUS5.BITNET

root@yale.UUCP (Celray Stalk) (08/23/88)

In article <8808230057.AA13653@ucbvax.Berkeley.EDU> MCCABE@MTUS5.BITNET writes:
>Subject: Personal Pascal question
> ...
>          Too many external references
> ...
>Does anyone have any ideas on this?

Two things to look at:

1.  The +E compiler switch, if I remember correctly, causes ALL global
symbols to become external.  I think it is on by default.  Since you
have so many global symbols, you might want to try turning it off and
explicitly declaring just those you need. 

2.  You can get by with only one global variable by defining a record
with 97 fields and having one global variable of that record type.
But a much better style is to organize them into related groups of
variables, and to make each group a structure with an associated
global variable of that type.  This should make the program much
cleaner and easier to maintain.  Having done so, you might then decide
that it is no longer so onerous passing around these structures as VAR
parameters and get rid of the global variables altogether!

==================================================
| Michael Fischer                                |
|    Arpanet:    <fischer-michael@cs.yale.edu>   |
|    Bitnet:     <fischer-michael@yalecs.bitnet> |
|    UUCP:       <fischer-michael@yale.UUCP>     |
==================================================

lohse@fbihh.UUCP (J. Lohse) (08/25/88)

> From:    Jim McCabe                                      MCCABE at MTUS5
> To:      INFO-ATARI16 at SCORE.STANFORD.EDU
> Subject: Personal Pascal question
> 
> This is directed to people who really know a lot about Personal Pascal, or
> those who have written huge programs in it.
> 
Let me try to answer: I am the author of the Personal Pascal package.

> Today, while rewriting the editor in a BBS of mine, my source code
> stopped compiling.  The compiler gets to the last line of the file
> ("end."), and stops with the error
> 
>           Too many external references
> 
The 1.xx versions allocated all external references (EXTERNAL procedures 
at their first call, runtime routines and top level procedures when {$E+})
in an array having only 100 entries.

When you get this message at the very end of the program the runtime routine
'close' probably is the 101st entry...

This size in increased to 300 in the newer 2.xx versions. But since I didn't
receive royalties for 17 months there won't be a recent version
distributed in US.
The current German version (ST Pascal Plus) is 2.04.

> me a linking error, saying that the function "bssanf" is undeclared.
> My program doesn't use any function bssanf.  :)

The symbol bssanf (bss-Anfang) is defined in the main module. This message
occurs if you link modules but no main program. All lowercase symbols
are internals. User declared symbols are always translated to uppercase.

                                                      Joerg Lohse
-- 
UUCP: lohse@fbihh.uucp                          | Universitaet Hamburg
      (...!uunet!unido!fbihh!lohse)             | Fachbereich Informatik
EAN:  lohse@rz.informatik.uni-hamburg.dbp.de    | Schlueterstr. 70
Phone: +49 40 4123 4141                         | D-2000 Hamburg 13 (W-Germany)