What I experienced
after Generics Introduced into Go
intermediate
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
郭學聰 Hsueh-Tsung Kuo
Sun, 30 Jul 2023
Someone (who?) said:
a game programmer should be able to draw cute anime character(?)
"algorithms are written in terms of data types to-be-specified-later that are then instantiated when needed for specific types provided as parameters."
C++
Java
Rust
C#
Rust
https://gobyexample.com/generics
好油喔peko
Learn More →
but permit to access interface methods
go 1.18~1.20
Monomorphic
Interface
Generics (pointer arg)
Generics (interface arg)
*AnyType
SerializeG[go.shape.*uint8_0]
Interface
SerializeG[go.shape.interface { ... }_0]
pointer arg
dict
+ iface.itab.fun
runtime.assertI2I()
+ iface.itab.fun
string
SequenceToString[go.shape.string_0]
[]byte
SequenceToString[go.shape.[]uint8_0]
https://github.com/koykov/byteseq
plain
plain (inlined)
parametrize callback parameter
parametrize callback parameter (not inlined)
parametrize callback
parametrize callback (inlined)
parametrize callback and its parameter
parametrize callback and its parameter (inlined)
good practice
good practice
bad practice
bad practice
acceptable?
practically impossible
type Byteseq interface{ ~string | ~[]byte }
郭學聰 Hsueh-Tsung Kuo2023_07_30
Image Not Showing Possible ReasonsLearn More →
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported