Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!brl-adm!brl-smoke!smoke!rbj@icst-cmr.ARPA From: rbj@icst-cmr.ARPA (Root Boy Jim) Newsgroups: net.lang.c Subject: Re: Swap by name Message-ID: <2036@brl-smoke.ARPA> Date: Tue, 8-Jul-86 20:20:54 EDT Article-I.D.: brl-smok.2036 Posted: Tue Jul 8 20:20:54 1986 Date-Received: Wed, 9-Jul-86 06:51:22 EDT Sender: news@brl-smoke.ARPA Lines: 46 > ~> call by value-result > > I was thinking of the caller squirrelling away the value > in a temporary location, passing it by reference (thus > allowing modification by the callee) and then copying the > result to the real variable. [me] > > That works too---which just goes to show that there is more than > one way to skin a function. [chris@maryland (as in Torek)] Changing the subject a bit here, I am referencing Wayne Throop's article on taking the address of a register variable, where he quotes H&S (how about that folks, they're mainstream enuf to be ref'ed like K&R). I have said all along that there is no reason why a compiler can't perform the following transformation: LEGAL DESIRED foo() foo() { register int j; { register int j; auto int k; k = j; bar(&k); bar(&j); j = k; } } Sort of a Call by Value-Result, eh? As H&S notes, some machines have registers that really *are* addressable, so this does provide something that is missing, and is not just syntactic sugaring. Even if it were, look at all the language implementation chatter we have removed. Just let the user say what he means. I agree with H&S that the syntax `ought' not to be illegal, but go the other way with the fix. They wish to ignore the register declaration making the variable auto, whereas I wish to simulate register addressibility. Consider a function which uses a register variable heavily in three or four loops. Now consider modifying the code to include a call to one that wants the address of a variable. Oops! All too often the fix is to change the register declaration to auto rather than add the extra variable and two assignments. Down the drain goes performance. (Root Boy) Jim Cottrell Yow! Is my fallout shelter termite proof?