More NULL questions
Chris Torek
chris at mimsy.UUCP
Thu Oct 12 03:34:27 AEST 1989
>In article <903 at abvax.UUCP> aep at 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 at shodha.dec.com> devine at 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 at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list