On Tue, 21 Mar 2017 04:48:50 +0000 Harley Laue <losinggenerat...@gmail.com> wrote:
> I have some code that I've sat on for some time: > > type Cell int > type Function func() error > > func cellToFunction(c Cell) *Function { > p := unsafe.Pointer(uintptr(c)) > if p == nil { return nil } > return (*Function)(p) > } > > func functionToCell(w *Function) Cell { > return Cell(uintptr(unsafe.Pointer(w))) > } > > It's not []byte, but the idea is similar. There are a few major > gotchas. After functionToCell, it's possible for the function to be > garbage collected. The function type must be known ahead of time for > cellToFunction. There's no way that I know to get arbitrary functions. It's actually an "interpret a pointer as pointing to a function of certain type"; the questio is: how do you get the runnable code to point that pointer at? In the original question, the OP tried to interpret a file presumably containing Go source code. -- 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. For more options, visit https://groups.google.com/d/optout.