This is the talk page for discussing improvements to the Function pointer article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
![]() | This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||||
|
this is a pointer to object. To access its member's data, one needs to dereference this first and then to dereference that member if it is a pointer. Pointer-to-member operators are not related to this. Citing cppreference: When a non-static class member is used in any of the contexts where the this keyword is allowed (non-static member function bodies, member initializer lists, default member initializers), the implicit this-> is automatically added before the name, resulting in a member access expression (which, if the member is a virtual member function, results in a virtual function call). — Preceding unsigned comment added by 5.20.191.37 (talk) 21:12, 27 December 2022 (UTC)
Function pointers in C and C++ are both type-safe. How are they any less type-safe than, say delegates in C#? I keep hearing this untrue statement. — Preceding unsigned comment added by 130.76.96.111 (talk) 19:13, 6 September 2013 (UTC)
Perhaps there could be something here showing how the same thing can be achieved using Object Oriented Programming? Ubermonkey 20:35, 2 Apr 2005 (UTC)
Also a nice implementation of this using a class where the method is passed as a function pointer (so a method pointer i guess). I've been trying to find an example of this everywhere and i can't find it. -Sharth --128.175.13.43 17:54, 26 October 2005 (UTC)
It would also be nice if the program actually worked.. say.. if it had a definition for the "list" or "listnode" types. Fresheneesz 07:56, 5 June 2006 (UTC)
public interface Foo { public abstract int perf(int a); } class MyFoo implements Foo { public int perf(int a) { return (2*a + 3); } } public class Test { static Foo s_func; public static void main(String[] args) { int x; setFunc(new MyFoo()); x = callFunc(10); } void setFunc(Foo f) { s_func = f; } int callFunc(int a) { return s_func.perf(a); } }
"Imagine rewriting the above code without function pointers. The fsum() and fproduct() function would both require loops iterating through the linked list." Isn't it contradicting to say that when the code does exactly that--or am I missing something? Guardian653 03:55, 2 December 2006 (UTC)
Procedural parameter seems to have a lot in common with this article. If someone agrees, should these two articles mention each other, or maybe even be merged? --Abdull (talk) 11:58, 26 July 2008 (UTC)
Java's lack of function pointers should be noted/explained. Fig (talk) 14:01, 30 September 2013 (UTC)
Comparable
interface, which is fine if a class needs one way to compare. But there is also Comparator
for more complicated cases. I do find the asymmetry of Comparable
funny, though. Gah4 (talk) 07:51, 4 April 2025 (UTC)Hello fellow Wikipedians,
I have just modified one external link on Function pointer. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}}
(last update: 5 June 2024).
Cheers.—InternetArchiveBot (Report bug) 21:49, 8 October 2017 (UTC)
The article mentions simple function pointers containing just the address, and also PL/I. There is a complication in PL/I due to internal procedures, and the context. That is, which level of nesting of the variables are seen when the ENTRY
variable is used. I believe this complication delayed internal procedures, and the ability to call them, in Fortran for many years. Last I knew, Fortran only allowed one nesting level for internal procedures. (Might have changed.) Do other languages have this complication? Gah4 (talk) 18:34, 3 April 2025 (UTC)
As noted here, or in the article, languages like PL/I need context. A recent edit indicates that context supplies in internal procedure with access to the current values of variables in enclosing procedures. I believe, though, that sometimes the are not the current values, and that is the complication. They should be the values that were current when the ENTRY
variable was given a value. Depending on what one does with recursion, that may have changed in the mean time.
Fortran had the ability to pass a function or subroutine name as an actual argument to another routine, since close to the beginning, and in the Fortran 66 standard. Not actually variables, though. But, as implemented no context, as there was no recursion and no internal procedures. When they did add internal procedures, they only allow one nesting depth. And did not allow them as actual arguments. I think that has changed since, but it took a long time. And the need for context was (one of) the complications. Gah4 (talk) 07:33, 5 April 2025 (UTC)