Go 1.18 generics
Looks like generics are still somewhat experimental in 1.18 and support for them will be improved and extended in future versions, so it's likely we'll only use them with 1.19 or later. Still, in this bug we can already collect ideas for their usage.
-
util/slicepackage is a low hanging fruit. - We can get rid of reflection for
GetVarSizeand array marshaling inio. I have tried to do it in a single function and it was a mess because of the need to specify 2 types explicitly. However if we split this in 2 functions (one for array of pointers, another for array of raw structs) things may look better.
- Client-side RPC iterators.
- WSClient subscriptions.
Type-specific vm.Stack can be nice too.
We can also add generic wrappers for event-related methods that can be generated by RPC binding generator (*EventsFromApplicationLog, etc), see https://github.com/nspcc-dev/neo-go/pull/3008#discussion_r1202990441.
https://github.com/nspcc-dev/neo-go/issues/3100 can also be supported using generics.