Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!boulder!pratt From: pratt@boulder.Colorado.EDU (Jonathan Pratt) Newsgroups: comp.sys.mac.programmer Subject: Re: XFCN/XCMD string in LSC C v3.0 Message-ID: <8150@boulder.Colorado.EDU> Date: 15 Apr 89 03:10:51 GMT References: <1583@ccnysci.UUCP> <2788@pegasus.ATT.COM> Sender: news@boulder.Colorado.EDU Reply-To: pratt@boulder.Colorado.EDU (Jonathan Pratt) Organization: University of Colorado, Boulder Lines: 20 In article <2788@pegasus.ATT.COM> ech@pegasus.ATT.COM (Edward C Horvath) writes: >You're not dense: the easiest way for a pascal programmer to end-run the >globals problem is to declare a "main" PROCEDURE and nest all the >subroutines within it. > I just wanted to point out that C programmers can emulate this nested globals behavior by doing manually what the Pascal compiler does auto- magically: simply define the globals as a struct var in the procedure designated as "main" and pass a pointer to this struct to each "nested" procedure. Pascal does this with hidden arguments. Yes, it does get a bit ugly if the nesting grows deep. I noticed that LSP does a pretty nice job of this for single nesting; Address register A4 picks up the hidden globals pointer, so there isn't much overhead. Jonathan /* Jonathan Pratt Internet: pratt@boulder.colorado.edu * * Campus Box 525 uucp: ..!{ncar|nbires}!boulder!pratt * * University of Colorado * * Boulder, CO 80309 Phone: (303) 492-4293 */