Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!brl-adm!brl-smoke!smoke!chris@maryland.ARPA From: chris@maryland.ARPA (Chris Torek) Newsgroups: net.lang.c Subject: Re: Swap by name Message-ID: <1965@brl-smoke.ARPA> Date: Fri, 4-Jul-86 20:47:52 EDT Article-I.D.: brl-smok.1965 Posted: Fri Jul 4 20:47:52 1986 Date-Received: Sat, 5-Jul-86 08:45:05 EDT Sender: news@brl-smoke.ARPA Lines: 47 From: Root Boy Jim > I merely chose a poor example. Call by reference and call > by name often have identical effects. [me] That doesn't mean they are the same. [rbj] That was my point. They are not the same, except in a particular set of cases. That is why (and when) it is important to know what methods of parameter passing are legal in whatever language you are using. I would dispute that no one uses call by name. Consider that in APL you can pass a character string and execute it to get the result. I suppose I am splitting hairs, but the effect is the same. I imagine one could do the same thing in LISP, or any interpretive language. Actually, this is a good point. In Lisp, a fexpr is in fact a sort of call-by-name, though depending on your scope rules it may do something very unexpected: evaluating `v' in the callee may provide the callee's `v', rather than the caller's. This is a particularly nasty problem in Gosling Emacs MLisp, where all MLisp `arguments' are in fact fexpr's. However, I stand by my statement, at least with a little modification: no one wants to be forced to use call by name exclusively. (Not that other methods are not available in Algol.) And I understand taht Common Lisp does not have fexpr's. ~> 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. That works too---which just goes to show that there is more than one way to skin a function. `A swap, by any call by name, would smell as sweet ....' `You can call me Ref, or you can call me Val, ....' -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu