lxn/walk — Issue #9: Event function handling needs to be redone for Go 1
Author: bsiegert
Created: 2011-12-14 09:51:02+00:00
State: open

In Go 1 (and at tip right now), it is illegal to compare function pointers against one another. Only comparisons against nil are allowed. In cancelevent.go (and the others!), Detach no longer compiles:

```go
func (e *CancelEvent) Detach(handler CancelEventHandler) {
for i, h := range e.handlers {
if h == handler {
e.handlers = append(e.handlers[:i], e.handlers[i+1:]...)
return
}
}
}
```

You can no longer do the `h == handler` comparison.

Proposal for a changed interface: return a handle which is equal to the index of the function. Make Detach take (index int) and do `e.handlers[index] = nil`. In Publish, call the function only if non-nil.

Ideally, there would be a common signature for the different kinds of handler functions and only one Event type with different instances ...