What is a Go function variable?
In Go as it is presently…
- Function variables are pointers
- They point to small structs
- Those structs contain either
- just the pointer to the function code for simple functions
- or to pointers to autogenerated wrapper functions and receivers &/or function parameters in the case of method calls and closures.
And why can’t you compare them? I expect it was just too hard to agree to a convention about which pointers would be considered equal when there are closures and method calls and function wrappers around.
Source: What is a Go function variable?, an article by Phil Pearl.