cdecl keyword

Barry Margolin barmar at think.COM
Sat Apr 2 07:52:42 AEST 1988


In article <3867 at super.upenn.edu> shirono at grasp.cis.upenn.edu (Roberto Shironoshita) writes:
>In article <2521 at bsu-cs.UUCP> dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
>>With a little foresight Microsoft could have just used the same calling
>>convention in all its language translators.
>I am of the belief that most languages have their own calling
>conventions: FORTRAN uses pass-by-reference for everything (at least,
>that's what I heard last); PASCAL uses pass-by-value for regular
>parameters, and pass-by-reference for VAR parameters.  C uses
>pass-by-value for everything.

Yes, but that doesn't preclude them all using the same internal
mechanism to actually make the call.  For example, if the internal
mechanism is pass-by-value, the languages whose semantics specify
pass-by-reference can automatically pass addresses.  Alternatively, if
the internal mechanism is pass-by-reference, by-value languages can
simply copy arguments to stack temporaries and pass references to
those locations (just as is done when a computed value is passed by a
by-reference language).

Another possibility is for the caller to pass a flag indicating
whether the arguments are values or references.  If the callee
is in a language that has the opposite semantics it can do the
appropriate conversion at that time.  Since most calls would be
between modules in the same language, this would be pretty cheap.

Barry Margolin
Thinking Machines Corp.

barmar at think.com
uunet!think!barmar



More information about the Comp.lang.c mailing list