Xref: utzoo comp.lang.c:8772 comp.sys.ibm.pc:13961 Path: utzoo!utgpu!water!watmath!clyde!ima!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: cdecl keyword Keywords: cdecl MicroSoft C Message-ID: <18733@think.UUCP> Date: 1 Apr 88 21:52:42 GMT References: <1238@wjvax.UUCP> <297@ho7cad.ATT.COM> <1242@wjvax.UUCP> <7595@brl-smoke.ARPA> <2521@bsu-cs.UUCP> <3867@super.upenn.edu> Sender: usenet@think.UUCP Reply-To: barmar@fafnir.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 30 In article <3867@super.upenn.edu> shirono@grasp.cis.upenn.edu (Roberto Shironoshita) writes: >In article <2521@bsu-cs.UUCP> dhesi@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@think.com uunet!think!barmar