https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/PosV49dhKCA[1-25]?
On Wednesday, August 29, 2012 2:37:07 AM UTC-7, Erik Unger wrote:
I think it would be useful to extend the language to allow binding
of object + method as a function value that can be called without having to
pass the object as first argument.
Why? I have seen multiple instances of reflection being used to wrap
method calls by using an object pointer and the method name as string. This
dynamic behavior wouldn't be necessary, if bound methods and functions
could be called with the same interface.
reflect.Value.Method() already does method binding, why not have it in the
language?
Of course, a binary function pointer compatible implementation would be
tricky, but not impossible.
The function code that prepends the address of the object to argument
list could get generated on the fly when an object+method gets assigned to
a function pointer.
-Erik
I think it would be useful to extend the language to allow binding
of object + method as a function value that can be called without having to
pass the object as first argument.
Why? I have seen multiple instances of reflection being used to wrap
method calls by using an object pointer and the method name as string. This
dynamic behavior wouldn't be necessary, if bound methods and functions
could be called with the same interface.
reflect.Value.Method() already does method binding, why not have it in the
language?
Of course, a binary function pointer compatible implementation would be
tricky, but not impossible.
The function code that prepends the address of the object to argument
list could get generated on the fly when an object+method gets assigned to
a function pointer.
-Erik