zellers@prisoner.Eng.Sun.COM (Steve Zellers) (10/10/90)
In article <17038@unix.SRI.COM> mxmora@unix.UUCP (Matt Mora) writes: >;(1) long compinit (maxbits, block_compress, outputfn, param) >; int maxbits, block_compress; >; int (*outputfn)(); >; long param; In pascal, you can declare: function compinit ( maxbits: longint; (* NOTE: longint, cuz in MPW C int==32bits *) block_compress: longint; outputfn: procptr; param: longint): handle; c; ..... hmumble := compinit (18, 42, @mycompare, nil); BUT! You only know 'param' is NULL if 'outputfn' is NOT a locally nested procedure. If it is nested, then 'param' has to point to the stack frame, which is not normally acessable via pascal. SO, in order to get pascal to do the work, you have to reorder the parameters from the C-style l-to-r, to the pascal style r-to-l, thus: program wombat; uses etc, etc, etc; var hmumble: handle; function compinit( function outputfn: (* 'param' is integral to this 'type' *) longint; block_compress: longint; maxbits: longint): longint; external; function mycompare: longint; begin DebugStr('got here'); end; (*mycompare*) begin hmumble := compinit(mycompare, 42, 18); (* NOTE that you don't 'take the address of' mycompare - pascal knows that when you pass a procedural parameter, to send the ProcPtr, and the 'param' field. *) end; (*wombat*) I recommend this latter approach, since it does all your type checking for you, and can be seen as more 'pascalish'. >Matthew Mora | my Mac Matt_Mora@sri.com >SRI International | my unix mxmora@unix.sri.com >___________________________________________________________ -- ------------------------------------------------------------------------ Steve Zellers zellers@prisoner.sun.com "All you slimy fruitcakes in San Fransisco are going to find out how to get to 180 and the letter 'G'. I repeat, there is No Other Possibility."