Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread 'Axel Wagner' via golang-nuts
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

Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread Jan Mercl
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

Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread julio
> > 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

Re: [go-nuts] Assigning a value to a function pointer

2019-12-23 Thread Jan Mercl
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

[go-nuts] Assigning a value to a function pointer

2019-12-23 Thread julio
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