Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: More NULL questions Message-ID: <20113@mimsy.UUCP> Date: 11 Oct 89 17:34:27 GMT References: <5950001@hpldola.HP.COM> <443@shodha.dec.com> <903@abvax.UUCP> <448@shodha.dec.com> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 31 >In article <903@abvax.UUCP> aep@ivan (Alex E. Pensky) writes: >>Even if pointers and integers are the same size and have the same >>representation, you are still in trouble if your compiler passes int >>parameters and pointer parameters via different mechanisms. ... In article <448@shodha.dec.com> devine@shodha.dec.com (Bob Devine) writes: > What different mechanisms? C only supports call-by-value for >parameters (I'm ignoring the special casing of arrays here). How >can pointers be passed differently than ints? It sounds like you >used a broken compiler. I dare say Mr. Pensky meant `different machine mechanisms that both implement call-by-value'. For instance, it is generally a Good Thing to pass one or two parameters in registers, rather than on the stack, on many machines. As an example, consider the 680x0 (x=0,1,2,3). On this CPU, pointers fit best in address registers (a0..a7) and integers fit best in data register (d0..d7). One could pass the first two pointer arguments in a0 and a1, and the first two integer arguments in d0 and d1 (allowing up to four arguments without any memory traffic). (Incidentally, the `special case for arrays' is at a higher level than argument passing. Arguments are expressions (rvalues) and arrays in such contexts are converted to pointers by the rule I am constantly describing. Since pointers are normally used to effect call-by-reference when needed, and since array declarations of formal parameters are quietly converted to pointer declarations, the language `fakes up' call-by-reference for arrays, but in truth something else is going on entirely.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris