On Thu, Oct 12, 2023 at 5:06 AM Pascal Costanza
<pascal.costa...@intel.com> wrote:
>
> I have a question about runtime.Pinner: The documentation states that you can 
> only pin an object when it’s the result of calling new, taking the address of 
> a composite literal, or taking the address of a local variable.
>
> At the same time, the Go language specification states that a slice created 
> with make allocates a hidden array, and gives the example that make([]int, 
> 50, 100) is the same as new([100]int)[0:50].
>
> Taken together, this suggests that the following sequence should be correct:
>
> var p runtime.Pinner
> s := make([]int, 100)
> p.Pin(&s[0])
>
> …since &s[0] can be understood as being the result of calling new.
>
> Is that intended?

Yes.


> Also: I believe it would be good if the documentation would state that the 
> zero value for type runtime.Pinner is ready to use.

That's the general default behavior for types in the standard library.
If nothing says otherwise, the zero value is ready to use.  That said,
I'm not opposed to mentioning it if someone wants to send a patch.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXa4O0vzPD8XfTPpLaojL-xOC0Rs1PvspM5G0qzF-i1vQ%40mail.gmail.com.

Reply via email to