| dbpprop:abstract
|
- A function pointer is a type of pointer in C, C++, D, and other C-like programming languages. When dereferenced, a function pointer invokes a function, passing it zero or more arguments just like a normal function. In programming languages like C, function pointers can be used to simplify code by providing a simple way to select a function to execute based on run-time values. Function objects, or functors, are similar to function pointers, and can be used in similar ways. A functor is an object of a class type that implements the function-call operator, allowing the object to be used within expressions using the same syntax as a function call. Functors are more powerful than simple function pointers, being able to contain their own data values, and allowing the programmer to emulate closures, among other uses. Many "pure" object-oriented languages do not support function pointers. Something similar can be implemented in these kinds of languages, though, using references to interfaces that define a single member function. Microsoft . NET languages such as C# and Visual Basic . NET implement type-safe function pointers with delegates. In other languages that support first-class functions, functions are regarded as data, and can be passed, returned, and created dynamically directly by other functions, eliminating the need for function pointers. Extensively using function pointers to call functions may produce a slow-down for the code on modern processors, because branch prediction may not be able to figure out where to branch to (it depends on the value of the function pointer at run time) although this effect can be overstated as it is often amply compensated for by significantly reduced non indexed table lookups.
- Un puntatore a funzione è un tipo di puntatore in C, C++, D, e altri linguaggi di programmazioni stile C. Quando viene dereferenziato esso invoca una funzione, passandole zero o più argomenti come ad una funzione normale. Nei linguaggi di programmazione come il C, i puntatori a funzione possono essere usati per semplificare il codice fornendo un modo semplice per eseguire codice in base a paramentri determinati a run-time. Similarmente ai puntatori a funzione esistono le funzioni oggetto o funtori, che possono essere usati in maniera silime. I funtori sono più potenti dei puntatori a funzione perché possono contenere i propri valori. Alcuni linguaggi "puramente" ad oggetti non supportano i puntatori a funzione. Qualcosa di simile può essere implementato in questi tipi di linguaggi, sebbene, usando le reference alle interfacce questo definisce una singola funzione membro. Linguaggi Microsoft . NET come il C# e il Visual Basic . NET implementano dei puntatori a funzione type-safe con i delegate. In altri linguaggi che supportano le funzioni first-class, le funzioni sono trattate come dati e possono essere passate, ritornate e create dinamicamente da altre funzioni, eliminando la necessità di puntatori a funzione. L'uso eccessivo di puntatori a funzione può produrre un rallentamento del codice sui processori moderni, perché la branch prediction può non essere in grado di prevedere quale ramo verrà preso (dipende infatti dal valore del puntatore a funzione a run-time), sebbene questo effetto possa essere compensato per ridurre le ricerche nelle tabelle di lookup.
- 関数へのポインタは、C, C++, Dやその他Cを基にしたプログラミング言語におけるポインタの一種である。関数へのポインタを参照外し(デレファレンス)して実引数を与えると、そのポインタが指し示す関数を呼び出せる。Cなどのプログラミング言語では、switch文を置き換えてコードを単純にするために使われることがある。 関数オブジェクト(もしくはファンクタとも呼ぶ)も関数へのポインタと同じような使い方が可能だが、関数オブジェクトは関数呼出演算子を実装したクラスなどのオブジェクトであるという点が異なっている。そのため、関数オブジェクトはデータを保持でき、クロージャを再現することもできる。ゆえに、関数オブジェクトは、単純な関数へのポインタよりも強力である。 多くの「純粋な」オブジェクト指向プログラミング言語(Javaなど)では、関数へのポインタを使用できないが、そのような言語では、メソッドを1つだけ持つインタフェースを使用することで同様のことを行える。また、C#やVisual Basic . NETなどといった. NET Framework用の言語では、関数へのポインタを型安全にしたものとして、デリゲートが使用可能である。 第一級オブジェクトとして関数を使用できる言語では、関数も引数で渡したり、戻り値で返したり、他の関数から動的に作成したりできるなどデータ同様に扱えるため、関数へのポインタは必要とされない。
- Typ funkcyjny – typ zmiennych która jest interpretowana jako funkcja.
|
| rdfs:comment
|
- A function pointer is a type of pointer in C, C++, D, and other C-like programming languages. When dereferenced, a function pointer invokes a function, passing it zero or more arguments just like a normal function. In programming languages like C, function pointers can be used to simplify code by providing a simple way to select a function to execute based on run-time values. Function objects, or functors, are similar to function pointers, and can be used in similar ways.
- Un puntatore a funzione è un tipo di puntatore in C, C++, D, e altri linguaggi di programmazioni stile C. Quando viene dereferenziato esso invoca una funzione, passandole zero o più argomenti come ad una funzione normale. Nei linguaggi di programmazione come il C, i puntatori a funzione possono essere usati per semplificare il codice fornendo un modo semplice per eseguire codice in base a paramentri determinati a run-time.
- Typ funkcyjny – typ zmiennych która jest interpretowana jako funkcja.
|