Hello,
now I'm learning progamming language in university.
but i have some question.
in textbook. says there are four passing Mechanism
1) pass by value (inother words : call by value)
2) pass by reference (inother words: call by reference)
3) pass by value-result <- i have question this subject .
4) pass by name
pass by value-result
passing mechanism
1.The values of the arguments are copied into the fomal parameters.
2.The final values of the parameters are copied back out to the
arguments.
Characteristics of the Pass by Value-Result
-AKA copy-in , copy-out(copy-restore)
-no alias problem occurs(differ to the pass by reference in this
point)
-The order of copying the results may be important
ex)
Assume: pass by value-result
void square(int x,int y)
{
x*=x;
y*=y;
}
main()
{
int a=5;
int b=10;
square(a,b);
printf("a = %d b = %d\n",a,b);
}
output:
a=25 b=100
can understand! but what about this?
void p(int x,int y)
{
int sum,prod;
sum=x+y;
prod=x*x;
x=sum; //sum will be returned via x
y=prod; // prod will be returned via y
}
main()
{
int a=5;
p(a,a); // a == ??
}
What value of a?
Thanks to read. 11 9462 ki****@gmail.co m writes:
Hello,
now I'm learning progamming language in university.
but i have some question.
in textbook. says there are four passing Mechanism
1) pass by value (inother words : call by value)
2) pass by reference (inother words: call by reference)
3) pass by value-result <- i have question this subject .
You will get better advice in a more general newsgroup like
comp.programmin g. This group discusses C in which only values can be
passed to functions.
--
Ben.
In article <11************ *********@x35g2 000prf.googlegr oups.com>,
<ki****@gmail.c omwrote:
>1) pass by value (inother words : call by value) 2) pass by reference (inother words: call by reference) 3) pass by value-result <- i have question this subject . 4) pass by name
This isn't a C question, because C uses (1).
>Characteristic s of the Pass by Value-Result -AKA copy-in , copy-out(copy-restore) -no alias problem occurs(differ to the pass by reference in this point) -The order of copying the results may be important
>void p(int x,int y) { int sum,prod; sum=x+y; prod=x*x; x=sum; //sum will be returned via x y=prod; // prod will be returned via y } main() { int a=5; p(a,a); // a == ?? }
What value of a?
As it says in the text you quoted, "the order of copying the results
may be important". If there's any programming language that uses
call-by-value-and-result, presumably its specification will answer
your question. Quite likely the answer will be "it's implementation
defined".
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963. ki****@gmail.co m wrote:
Hello,
now I'm learning progamming language in university.
Which one? Because we do C here; we're not a general prog-lang
newsgroup. You'd be better off in comp.lang.misc, I think,
or possibly comp.compilers.
but i have some question.
in textbook. says there are four passing Mechanism
1) pass by value (inother words : call by value)
2) pass by reference (inother words: call by reference)
3) pass by value-result <- i have question this subject .
4) pass by name
C has pass by value, and that's your lot.
[The apparent exception for arrays is just that; apparent; it's
not part of the parameter-passing mechanism, it's part of the
arrays-used-as-values-become-pointers-to-element-0 mechanism.]
So your syntactically-C pass-by-value-result can't be answered
here, because it's not a C question, but ...
main()
{
int a=5;
p(a,a); // a == ??
}
What value of a?
That would depend on the /actual language/ claiming to have
pass-by-value-result. Since we don't know what it is (but
we do know it isn't C, and might admit to knowing it isn't
C++), we can't say, and it would be atopical of us to do so.
(fx:OT)
If C mutated, Goldschmidt-like, to have pass-by-value-result
arguments as an option -- an event I regard about as likely as
railways to the moon or Buffy living a long and happy life --
then I'd expect it to say that if any of the value-result
arguments to a function overlapped The Results Are Undefined.
C's like that.
--
There' no hortage of vowel on Uenet.
Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England ki****@gmail.co m wrote:
(Stuff also appearing, it transpires, in comp.programmin g.)
PS It's not polite to multipost. Don't do it.
--
A rock is not a fact. A rock is a rock.
Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England
On Tue, 05 Jun 2007 15:54:44 +0100, Chris Dollin wrote:
>C has pass by value, and that's your lot.
C also has 'pass by address' (a.k.a. pointers).
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
Roland Pibinger said:
On Tue, 05 Jun 2007 15:54:44 +0100, Chris Dollin wrote:
>>C has pass by value, and that's your lot.
C also has 'pass by address' (a.k.a. pointers).
In C, pointer expressions are passed by value, just like any other
argument expressions.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.uk
email: rjh at the above domain, - www.
Roland Pibinger wrote:
On Tue, 05 Jun 2007 15:54:44 +0100, Chris Dollin wrote:
>>C has pass by value, and that's your lot.
C also has 'pass by address' (a.k.a. pointers).
My evil twin will be ready to point out that C does
/not/ have "pass by address". Using pointers is just
using pointers; there's no special parameter-passing
machinery involved. Contrast eg VAR parameters in Pascal.
--
Far-Fetched Hedgehog
The shortcuts are all full of people using them.
In article <46************ ***@news.utanet .at>,
Roland Pibinger <rp*****@yahoo. comwrote:
>>C has pass by value, and that's your lot.
>C also has 'pass by address' (a.k.a. pointers).
No, but you can pass pointers by value and dereference them in the
called function to achieve the effect of call-by-reference.
-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
In article <f4***********@ pc-news.cogsci.ed. ac.uk ri*****@cogsci. ed.ac.uk (Richard Tobin) writes:
In article <11************ *********@x35g2 000prf.googlegr oups.com>,
<ki****@gmail.c omwrote:
3) pass by value-result <- i have question this subject .
....
void p(int x,int y)
....
x=sum; //sum will be returned via x
y=prod; // prod will be returned via y
....
p(a,a); // a == ??
....
As it says in the text you quoted, "the order of copying the results
may be important". If there's any programming language that uses
call-by-value-and-result, presumably its specification will answer
your question. Quite likely the answer will be "it's implementation
defined".
The only programming language I know that allows for pass by value-result
is Fortran. But there the call p(a,a) is disallowed. (If two arguments
are aliases of each other, assignment to them in a subroutine is not
allowed.)
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: uli2003wien |
last post by:
Dear group,
PASS (SQL-Server user group) is about to start founding a branch in
Vienna. I went to SQLCON and met some guys from the German PASS group
and decided to become a member of PASS, decided to look for other
individuals to take part in an Austrian branch of PASS based in Vienna,
so whoever is interested may take a look at
http://www.sqlpass.de/Default.aspx?tabid=191 in order to get to contact
me to get things going....
|
by: Robert |
last post by:
when using the following function to create a pass through query is there a
way to set the query property, "Returns Rows" to no. The default is yes.
Since we are planning to create the pass through with new parameters in the
where clause we need to set it each time. Thanx in advnance.
Function CreateSPT(SPTQueryName As String, strSQL As String)
Dim cat As ADOX.Catalog
Dim cmd As ADODB.Command
|
by: Zlatko Matić |
last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL
Server) and that we want to execute some parameterized query as a
pass.through query. How can we pass parameters to the server ?
Is it possible to use parameters in pass-through queries ?
An additional question: Is it possible to connect to a database on MySQL or
PostgreSQL using ADO ?
Is it possible to execute pass-through queries with parameters, using ADO...
|
by: Alex Nitulescu |
last post by:
Hi.
I have tried to pass two parameters, like this:
Response.Redirect(String.Format("NewPage.aspx?Username={0}, Pass={1}",
txtUserName.Text, txtPass.Text))
But if I pass Username="Alex" and Pass="AAA", I get Params("Username") =
"alex, Pass=AAA" and Params("Pass")="", which is not what I expected.
|
by: Marcelo |
last post by:
Any suggestion?
Thanks
Marcelo
| |
by: ILCSP |
last post by:
Hello, I'm fairly new to the concept of running action pass through
queries (insert, update, etc.) from Access 2000. I have a SQL Server
2000 database and I'm using a Access 2K database as my front end.
I'm using a blank pass through query which gets the Transact-SQL part
inserted from a button in my form. After inserting the Transact-SQL
code into the pass through query, I 'open the recordset' to make the
query run.
However,...
|
by: Ronald S. Cook |
last post by:
I want to something as simple as:
UserControl uctTemp;
But the type will be passed in to the function (which will be an existing
user control like "uctMyUserControl1")
So, how can I pass in the string "uctMyUserControl1" and then somehow dim an
instance of it?
|
by: Remote_User |
last post by:
Hi,
Is there any way I can pass a file as a parameter? ( maybe read it
into a object) I am working on C# VS2005.
Thanks.
|
by: =?Utf-8?B?Umljaw==?= |
last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child)
but I need an example of passind data from FormA to FormB. My main form is
FormA; I will enter some data in textboxes and click a button to bring up
FormB which needs to display values entered in FormA.
Thanks in advance.
|
by: magickarle |
last post by:
Hi, I got a pass-through query (that takes about 15 mins to process)
I would like to integrate variables to it.
IE: something simple:
Select EmplID from empl_Lst
where empl_lst.timestamp between !! And
!!
Not sure how to do so (should it be a query in Access or a macro)
The connection would be ODBC.
|
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...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |