Call by Value

Call by Value

Wertparameter (engl. call by value) sind Parameter von Unterprogrammen in Programmiersprachen, die die Übergabe, jedoch nicht die Rückgabe von Werten ermöglichen. Neben Wertparametern stehen oft auch Referenzparameter zur Verfügung, die neben einer Wertübergabe auch deren Rückgabe ermöglichen.

Inhaltsverzeichnis

Beispiel

Die Programmiersprache C verwendet stets Wertparameter. Auch Zeiger werden als Wertparameter übergeben. De facto liegt dann aber für die Daten, auf den diese Zeiger verweisen, eine Übergabe by Reference vor.

Funktion:

int test(int s1, int s2)
{
    s1 = s1 * 3; 
    s2 = s2 * 4;
    return(s1 + s2); 
}

Aufruf:

int a = 4, b = 5, c;
c = test(a,b);
printf("%i, %i, %i", a, b, c);

Ausgabe:

4, 5, 32

In diesem Beispiel ist zu sehen, dass die beiden Variablen a und b lediglich ihre Werte an die Funktion test übergeben, aber im Gegensatz zu einem Referenzparameter dabei unverändert bleiben.

Felder werden in C stets als Zeiger übergeben.

Implementierung

Wird eine Zuweisung innerhalb des Unterprogrammes an einen Wertparameter vorgenommen, muss ein Compiler beim Unterprogrammaufruf eine Kopie des Parameters erzeugen. Hierfür ist sowohl Speicherplatz als auch Ausführungszeit erforderlich. Bei größeren Datenstrukturen, wie z. B. großen Feldern, kann dies problematisch sein.

Optimierende Compiler können automatisch ermitteln, ob eine solche Kopie nötig ist und gegebenenfalls darauf verzichten.

Verwendende Programmiersprachen

Siehe auch


Wikimedia Foundation.

Игры ⚽ Нужно решить контрольную?

Schlagen Sie auch in anderen Wörterbüchern nach:

  • Call by value — Wertparameter (engl. call by value) sind Parameter von Unterprogrammen in Programmiersprachen, die die Übergabe, jedoch nicht die Rückgabe von Werten ermöglichen. Neben Wertparametern stehen oft auch Referenzparameter zur Verfügung, die neben… …   Deutsch Wikipedia

  • call-by-value — noun An in which the arguments to a function are evaluated first, and the result is passed into the function …   Wiktionary

  • Call by reference — Referenzparameter (engl. call by reference) sind Parameter von Unterprogrammen in Programmiersprachen, die die Übergabe und Rückgabe von Werten ermöglichen. Ihr Name kommt daher, dass der Compiler in den meisten Programmiersprachen die Adresse… …   Deutsch Wikipedia

  • call-by-reference — noun An in which the arguments to a function are evaluated first, and a pointer to the result is passed to the function. , call by value , call by name , call by need , call by future …   Wiktionary

  • call profit — call profit/loss For a long call, equal to the call value minus the premium. For a short call, equal to the premium minus the call value.. Chicago Mercantile Exchange Glossary …   Financial and business terms

  • call loss — call profit/loss For a long call, equal to the call value minus the premium. For a short call, equal to the premium minus the call value.. Chicago Mercantile Exchange Glossary …   Financial and business terms

  • Value Added Tax-free Exports from the Channel Islands — are exports of goods from the Channel Islands on which value added tax (VAT) is not levied. In recent years, companies in the United Kingdom have expressed concern at the competition thereby offered to their goods on which VAT is… …   Wikipedia

  • call loan — ☆ call loan n. 1. a loan that must be repaid on demand 2. a loan to a broker that is secured by shares of stock purchased with the borrowed money and which may be called if the shares decline in value: also call money …   English World dictionary

  • Call stack — In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, control stack, run time stack, or machine stack, and… …   Wikipedia

  • Call option — This article is about financial options. For call options in general, see Option (law). A call option, often simply labeled a call , is a financial contract between two parties, the buyer and the seller of this type of option.[1] The buyer of the …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”