473,836 Members | 1,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

call by address vs. call by value

Why is "call by address" faster than "call by value"?
Nov 14 '05
35 10808
Jack Klein wrote:
Now consider a situation where there are not enough registers
available to cache the pointer in a register.


This was the case I did not see (Why on earth not ;).

Thanks.

--
Thomas.

Nov 14 '05 #31
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > wrote:
Jack Klein wrote:
Sometimes the pointer is bigger than the object.
And sometimes, even if the object is larger than the data,
the way you access the data via the pointer
might create more overhead
than accessing a local copy that was passed by value.


What would really be nice is an example (a simple benchmark)
that illustrated this effect for objects of different sizes
and measured the "break-even" size for user defined types (structs).


It would, at first glance, indeed look like this would be useful.
However, its actual value would be greatly diminished by the fact that
the measurements would vary greatly depending on platform,
implementation, and probably even compiler options. In short, you could
demonstrate the presence of the effect; but the break-even size pointed
at in the example could be made invalid by simply using -opt:hi instead
of -opt:medium, or by running it on a Z90 Mk. 4 instead of a Z90 Mk. 3.

Richard
Nov 14 '05 #32
On Tue, 10 Feb 2004 19:00:48 -0500 (EST), "Arthur J. O'Dwyer"
<aj*@nospam.and rew.cmu.edu> wrote:

On Tue, 10 Feb 2004, Leor Zolman wrote:

Colloquially, I usually use the terms "pass by value" and "pass by
name" (or reference, or pointer...altho ugh using "reference" can be
problematic in C++) /in close conjunction/ with the object being
passed that way.
While your statement can be read as correct, I'll nitpick over
the implied equivalence of "pass by name" and "pass by reference,"
which are very different things! See Google Groups for a number
of gigantic threads on the subject of what constitutes pass by
value/reference/copy-and-return/name/text/lazy-evaluation, et al.
C, C++, Java, and friends generally have no built-in equivalent
to pass-by-name. [The answer to your unasked question will be found
in Google Groups.]


"unasked question..." sounds like some sort of Zen koan ;-)

If you mean my wondering about how "pass by value" is defined in C
(and I first used the term "call by value" inadvertently; I'm only
talking about argument passing), I've been trying to nail that down
from the Standard, and so far I've been unable to locate any use of
"pass by" anything at all. I've also been told, in a private
discussion, that in the context of C the term "call by value" is
meaningless (this time I do mean "call"), yet ironically there's an
index entry for it in the Standard (it is the only result I get from
searching for "call by" using Acrobat Reader 6's find feature), but I
honestly have not been able to reason out exactly which paragraph of
section 6.5.2.2 it is referring to!

The conclusion I'm drawing from this so far, and this situation is
similar to the one I ran into in an attempt to pin down the precise
meaning of the standalone word "prototype" in the /C++/ Standard (my
conclusion there was that folks are free to use it to mean just about
anything they want, because the term is not specifically defined, and
only /used/ within the phrase "function prototype scope" borrowed from
the C Standard), is that it would not be unreasonable to interpret any
colloquial use of "pass by name", "pass by reference" and "pass by
address" /in the context of C/ to be effectively synonymous. Of
course, one has to consider the source, and the context, but that's
precisely what I try to do when answering a question. I'm on a
learning curve, here...
-leor


-Arthur


Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #33
Leor Zolman <le**@bdsoft.co m> wrote:
is that it would not be unreasonable to interpret any
colloquial use of "pass by name", "pass by reference" and "pass by
address" /in the context of C/ to be effectively synonymous.


Almost. In colloquial use, I would consider "pass by address" and "pass
by reference" to be synonymous with "pass a pointer to", with the
proviso that "pass by reference" is ambiguous if C++ gets involved,
which it sometimes does even though it shouldn't.
"Pass by name", however, is something else entirely, and something we
would do well to keep far away from. Here there be dragons. Basically,
"pass by name" is similar, yet dissimilar, to what C does with macros,
with all the strengths those have, and all its dangers as well.

Richard
Nov 14 '05 #34
In article <40************ *****@news.indi vidual.net> rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
....
"Pass by name", however, is something else entirely, and something we
would do well to keep far away from. Here there be dragons. Basically,
"pass by name" is similar, yet dissimilar, to what C does with macros,
with all the strengths those have, and all its dangers as well.


I have used it much to my advantage, but not in C of course.
(Jensen's device of course.) The difference with macro's is
of course that macro's are completely compile-time, call-by-name
is not.

(And then there is of course that article in Datamation where the
language Babbage was explained. It had call-by-telephone for
long-distance parameters.)
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #35
Richard Bos wrote:
E. Robert Tisdale wrote:
Jack Klein wrote:
Sometimes the pointer is bigger than the object.
And sometimes, even if the object is larger than the data,
the way you access the data via the pointer
might create more overhead
than accessing a local copy that was passed by value.


What would really be nice is an example (a simple benchmark)
that illustrated this effect for objects of different sizes
and measured the "break-even" size for user defined types (structs).


It would, at first glance, indeed look like this would be useful.
However, its actual value would be greatly diminished by the fact that
the measurements would vary greatly depending on platform,
implementation, and probably even compiler options.
In short, you could demonstrate the presence of the effect;
but the break-even size pointed at in the example
could be made invalid by simply using -opt:hi instead of -opt:medium,
or by running it on a Z90 Mk. 4 instead of a Z90 Mk. 3.


It sure would be nice to have an example that we could use
to confirm or refute all of this conjecture. :-)

Nov 14 '05 #36

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
46971
by: ¤ Alias | last post by:
I have a function named getID3info (lvwDiscInfo.SelectedItem). What is the difference between getID3info (lvwDiscInfo.SelectedItem) and Call getID3info(lvwDiscInfo.SelectedItem) ?
46
2278
by: TTroy | last post by:
Hi, I'm just wondering why people/books/experts say "the function returns a pointer to.." or "we have to send scanf a pointer to.." instead of "the function returns the address of.." or "we have to send scanf the address of.." Isn't the lvalue called a POINTER TO and the (r)value called the ADDRESS OF?
8
1963
by: Berhack | last post by:
I am not too familiar with C# interop so please help me out. I need to call the following C function (in a DLL): // this creates an array of strings // LPTSTR is just char * void C_Func(LPTSTR **pszStrings) { (*pszStrings) = reinterpret_cast<LPTSTR *>(malloc(2 * sizeof(LPTSTR))); (*pszStrings) = _T("A test");
1
3219
by: Eric | last post by:
When I run my script it gives error on the following line: strEmail = Right(strEmail, (Len(strEmail) - 1)) I enclose my code and the sample text file too Thanks, ----------------------------------------------------------------------------- Option Compare Database Option Explicit Private Sub Command26_Click()
275
12487
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
21
479
by: coolguyaroundyou | last post by:
See the below code: void func(int x) { printf("%d",x); } int main() { int j=0;
0
9814
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9666
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10836
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10585
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7786
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4447
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4009
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.