If what you want is a) assume that a `func()` is pointer-shaped and b)
treat it as an unsafe.Pointer for use with atomics, then that's a problem
that - as all problems in computer science - can be solved with another
layer of indirection: https://play.golang.org/p/o0DvCxPTG1O
As Jan mentioned, a
On Mon, Dec 23, 2019 at 6:41 PM wrote:
>> > But I cannot find any way of assigning a value to the function pointer `f`
>> > even using the `unsafe` package.
>>
>> https://play.golang.org/p/qP5kuSCW6dO
>
> Thanks, unfortunately the asm shows that what gets into `f` is the stack
> address of
> > But I cannot find any way of assigning a value to the function pointer
> `f` even using the `unsafe` package.
>
> https://play.golang.org/p/qP5kuSCW6dO
>
Thanks, unfortunately the asm shows that what gets into `f` is the stack
address of `f0` and not the address of the function:
LEAQ
On Mon, Dec 23, 2019 at 2:49 PM wrote:
> But I cannot find any way of assigning a value to the function pointer `f`
> even using the `unsafe` package.
https://play.golang.org/p/qP5kuSCW6dO
Note that while you can a pointer to a function, you rarely need that.
Function is just a value like int
Hello,
The following Go program has a valid syntax:
https://play.golang.org/p/V7bIGnTu1fb
But I cannot find any way of assigning a value to the function pointer `f`
even using the `unsafe` package.
My main reason for willing this is to be able to:
- atomically load a dynamic address.
- avoid