5 ms·
This isn't true. You could use the adapter pattern and require that your reactive elements implement some kind of sane interface and then you're not using inter
by mevile 10y ago
This isn't true. You could use the adapter pattern and require that your reactive elements implement some kind of sane interface and then you're not using interface{} everywhere. It's not as flexible as generics but it's possible. This is how you do promises in go, with the adapter pattern.
- malcolmgreaves 10y agoBut then that interface needs to specify the behavior. And -- crucially -- ONLY that behavior. It's not possible in Go to say "this thing is unknown, but it will have a specific behavior (type) at compile time." interface{} says it is known type that has no behavior.
- chewxy 10y agoIs that not the definition of what a interface is? If you want something that prints you define a printer interface that has exactly one method. Go highly encourages small interfaces
- grey-area 10y agoIn go: An interface says this thing is unknown but it has at least these known methods The empty interface means this thing is unknown and its methods are unknown The first is preferable and the second is not often used.
- bsaul 10y agoThe problem is we need the distinction between "author of the code" unknown ( in which case whatever symbol such as T is enough), and "user of the code" unknown ( in which case relying on dynamic casting or interfaces is fine). What go doesn't provide is 1/ unknown but 2/ not. Which happens when you're creating a lib to be used later.