[go-nuts] Re: [golang-dev] Binding receiver object to a method expression, to get a method value

2017-01-19 Thread Jordan Krage
Would a simple single method interface meet your needs? type fooer interface { foo() bool } func (a *A) foo() bool { ... } func bar(f fooer) { if f.foo() { ... } } func main() { a := { ... } bar(a) } On Wednesday, January 18, 2017 at 8:55:07 PM UTC-6, Bryan Chan

[go-nuts] Re: [golang-dev] Binding receiver object to a method expression, to get a method value

2017-01-18 Thread minux
On Wed, Jan 18, 2017 at 9:55 PM, Bryan Chan wrote: > On Wednesday, 18 January 2017 16:39:03 UTC-5, rog wrote: >> >> On 18 January 2017 at 18:45, Bryan Chan wrote: >> > But I couldn't find a way to bind a receiver to a method expression, >> such >> > that

[go-nuts] Re: [golang-dev] Binding receiver object to a method expression, to get a method value

2017-01-18 Thread Tamás Gulácsi
No, but you can create a function/closure which gets the receiver as first arg, and either executes the method with the given args, or returns such a function, as you wish. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

[go-nuts] Re: [golang-dev] Binding receiver object to a method expression, to get a method value

2017-01-18 Thread Bryan Chan
On Wednesday, 18 January 2017 16:39:03 UTC-5, rog wrote: > > On 18 January 2017 at 18:45, Bryan Chan > wrote: > > But I couldn't find a way to bind a receiver to a method expression, > such > > that the resulting method value can be invoked at a later time. Would > this

[go-nuts] Re: [golang-dev] Binding receiver object to a method expression, to get a method value

2017-01-18 Thread roger peppe
On 18 January 2017 at 18:45, Bryan Chan wrote: > In Go, you could pass a method value around so that the method can be > invoked later on a pre-determined receiver, e.g. > > func (a *A) foo() bool { ... } > > func bar(f func () bool) { > if f() { > ... > } > }