Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cica!gatech!psuvax1!schwartz From: schwartz@shire.cs.psu.edu (Scott Schwartz) Newsgroups: comp.lang.pascal Subject: Re: Turbo and Standard Pascal Message-ID: Date: 12 Jul 89 05:29:49 GMT References: <20172@adm.BRL.MIL> <4822@freja.diku.dk> <4249@eos.UUCP> <2075@csuna.csun.edu> Sender: news@psuvax1.cs.psu.edu Organization: Pennsylvania State University, computer science Lines: 23 In article <2075@csuna.csun.edu> abcscnuk@csuna.csun.edu (Naoto Kimura) writes: [ Correctly diagnoses TP's problems with procedure parameters ] |Passing a procedure or function to another procedure or function means |basically at the low level, the address of the procedure or function being |passed is passed to the called procedure or function. The called procedure |then uses the address to perform an indirect call to the passed procedure |or function: This is not quite the whole story. In addition to the address of the function to be called, you need to pass the context of that function (the static link). For this reason, if no other, passing just addr(func) won't do the job properly. Even if you didn't screw up the stack, you'd be unable to correctly access func's global variables. On a slightly differen subject, handling procedure parameters correctly is the hardest part of translating Pascal to C mechanically. The most common tactic is to just punt. (Per Bergsten's otherwise excellent translator punts, for example.) -- Scott Schwartz