FAQ

On Mon, Sep 7, 2015 at 3:26 AM, Si Robertson wrote:
Essentially what I'm attempting to do is create some kind of event system
that uses callbacks as event handlers instead of requiring the use of
interfaces. The latter solves this problem but it quickly becomes
cumbersome.
It's still not obvious to me why an event system that uses callbacks
needs to compare function pointers.

In any case, I wouldn't recommend the fmt.Sprint approach. For example
consider two functions:

func a() {}
func b() {}

are their underlying function pointers equal or not? Similarly, suppose I had

func f() func() {
   return func(){
     println("closure")
   }
}

p := f()
q := f()

Are p and q's underlying function pointers equal or not? Different
compilers, or different versions of the same compiler, could return
different results, and you can't rely on any existing (undefined)
behavior staying that way in the future.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 10 of 14 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 6, '15 at 3:23p
activeSep 7, '15 at 2:42p
posts14
users9
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase