AlekSi / pointer

Go package pointer provides helpers to get pointers to values of built-in types.
MIT License
211 stars 19 forks source link

Changing semnatics of the functions #11

Closed royKarseboom closed 2 years ago

royKarseboom commented 2 years ago

Hi, I find the pointer.ToX(v X) *X a bit confusing since by reading it (without looking at the parameter and return value) I would think it would turn a pointer of X to the value X, which it doesn't. Maybe we could change it to ptr.OfX(v X) *X Also, in a similar manner, I think pointer.GetX(v *X) X would be clearer as ptr.ToX(v *X) X To summerize, I'm suggesting the following changes

pointer.ToX(v X) *X -> ptr.OfX(v X) *X
pointer.GetX(v *X) X -> ptr.ToX(v *X) X

I don't mind opening the PR, would you accept?

AlekSi commented 2 years ago

I read pointer.ToX(v X) as "[give me a] pointer to X".

In any case, that module will not have breaking changes in v1, and I plan to wait for https://github.com/golang/go/issues/9097 or https://github.com/golang/go/issues/45624 to be accepted and implemented before I release v2. If you want a different syntax, and you already have some module in from the list at #8 in dependencies, you might want to use them instead.