gnark-crypto
gnark-crypto copied to clipboard
Pointer/non-Pointer refceivers
Struct methods can take either pointer or value receivers. We have structs with methods of each type, which is currently discouraged by Go documentation. We should either fix all such instances or have an argument why not.
Just out of curiosity, can you explain what you mean when you say, we have structs with methods of both types ?
My incorrect interpretation of this sentence is:
type Foo uint64
func (f Foo) hello() {}
func (f *Foo) hello() {}
Incorrect because the above would not compile.
I guess it is better to say of each type:
type Foo uint64
func (f* Foo) hello() {}
func (f Foo) goodbye() {}
I guess it is better to say of each type:
type Foo uint64 func (f* Foo) hello() {} func (f Foo) goodbye() {}
Ah thanks for clarifying. To add more context to this issue, I found this article which also corroborates your position.
Makes sense, thank you!