Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!gitpyr!dsking From: dsking@pyr.gatech.EDU ( David King) Newsgroups: comp.sys.amiga.tech Subject: M2/C discussion (Re: Can you nest subroutines in C?) Message-ID: <8673@pyr.gatech.EDU> Date: 5 Jul 89 02:53:08 GMT References: <4524@crash.cts.com> <18213@usc.edu> Reply-To: dsking@pyr.UUCP ( David King) Organization: Georgia Institute of Technology Lines: 70 In article <18213@usc.edu> papa@pollux.usc.edu (Marco Papa) writes: >I've been told by a third party the this is not entirely true. Can you have >procedure pointers as fields of data structure as in: > >struct xpr { > long (*xpr_open)(); > long (*xpr_close)(); > .... >} > >... >struct xpr *io; > >io->xpr_open = MyOpen; >io->xpr_close = MyClose; > >Can you do that in M2? I'd really like to know? Also does M2 provide >setjmp/longjmp in one of the libraries? > Yep, you can do that in M2. Here's the equivalent code: TYPE xprType = RECORD xprOpen, xprClose : PROC; ... END; ... VAR io : xprType; ... WITH io DO xprOpen := MyOpen; xprClose := MyClose; END; (* With *) ... #ifdef RAMBLE I actually use this in my present project (when I have time I'm working on a very small terminal program since I don't have much free memory) to have all open windows use the same IDCMP port. Each window's UserData pointer references a structure/RECORD of procedure pointers for each type of message. I use this feature so much I go crazy on ISO pascal compilers. setjmp/longjmp? Its definately not part of the language definition (they actually aren't part of C's definition unless the ANSI committee added it in the last year), and I couldn't find anything like it in M2Sprint's definitions. *jmp actually are library routines on UNIX that got used in programs so much that they made it into most C systems. This brings up something I've been wondering - what are things like *jmp useful for in an Amiga program? #endif -David >-- Marco Papa 'Doc' >-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= >uucp:...!pollux!papa BIX:papa ARPAnet:pollux!papa@oberon.usc.edu >"There's Alpha, Beta, Gamma, Diga and Caligari!" -- Rick Unland >-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ^^^^^^^^ Slowly the list grows longer. Is this a progression towards the "ultimate" customers as debuggers? -- David King - FROM Disclaimers IMPORT Standard; Georgia Insitute of Technology, Atlanta Georgia, 30332 uucp: ...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!dsking ARPA: dsking@pyr.gatech.edu