By value-result vs by reference

guerin@iro.umontreal.ca (Frederic Guerin)
Thu, 21 Apr 1994 02:55:05 GMT

          From comp.compilers

Related articles
By value-result vs by reference guerin@iro.umontreal.ca (1994-04-21)
Re: By value-result vs by reference graham@pact.srf.ac.uk (1994-04-21)
By value-result vs by reference ssimmons@convex.com (1994-04-21)
Re: By value-result vs by reference hbaker@netcom.com (1994-04-21)
Re: By value-result vs by reference Dik.Winter@cwi.nl (1994-04-21)
Re: By value-result vs by reference nebbe@lglsun.epfl.ch (1994-04-22)
Re: By value-result vs by reference andrewd@apanix.apana.org.au (1994-04-24)
[7 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: guerin@iro.umontreal.ca (Frederic Guerin)
Keywords: design, question, comment
Organization: Universite de Montreal
Date: Thu, 21 Apr 1994 02:55:05 GMT

Hello,


I would like to hear about call-by-value-result vs call-by-reference,
which one is better ?


Most of the today popular languages have adopted the call-by-reference as
a mean to pass variable arguments to procedure-function.


But, if an argument does fit in a machine word, it seems more efficient to
pass the argument by value-result. Just one move is needed ( and may-be
another one on return ) like the call-by-reference. But then, no more
indirection.


In today's world of RISC machines, this can be a serious advantage. For
example, suppose one wished to increment a word variable with a user
defined function ( no built-in ++ or += and no inline ) like


word& Inc ( word& w ) { return w = w + 1; }


Then the machine must move the referenced word to register, increment it,
and then put it back to memory. In the call-by-value-result, the machine
just increments the word already in a register, and then moves it to its
return place ( if necessary ). Hence call-by-value-result cannot be worse
than call-by-reference on register-operand-only machines. Moreover, no
memory access ...


Is there some good reason to prohibit call-by-value-result that I can't see,
or is it coincidental of these days ?


Fred
[One point in favor of putting reference rather than value/result into a
language is that it's easy to roll your own v/r given ref, but difficult
the other way. It also seems to me that call by value with no result copied
back is more common than either v/r or ref. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.