Re: [go-nuts] []byte to func

2017-03-20 Thread Konstantin Khomoutov
On Tue, 21 Mar 2017 04:48:50 + Harley Laue 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)

Re: [go-nuts] []byte to func

2017-03-20 Thread Basile Starynkevitch
On Tuesday, March 21, 2017 at 4:04:34 AM UTC+1, Rob 'Commander' Pike wrote: > > No, Go does not have run-time evaluation of Go program source. It is > strictly a compiled language, although there are some (pieces of) > interpreters out there. > > > However, Go 1.8 has plugins

Re: [go-nuts] []byte to func

2017-03-20 Thread Sandeep Kalra
Thanks Harley. I will pick your example and will see if this is do-able... Sandeep Best Regards, Sandeep Kalra On Mon, Mar 20, 2017 at 11:48 PM, Harley Laue wrote: > I have some code that I've sat on for some time: > > type Cell int > type Function func() error > > func cellToFunction(c Ce

Re: [go-nuts] []byte to func

2017-03-20 Thread Harley Laue
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.

Re: [go-nuts] []byte to func

2017-03-20 Thread Sandeep Kalra
Thanks Rob! On Monday, March 20, 2017 at 10:04:34 PM UTC-5, Rob 'Commander' Pike wrote: > > No, Go does not have run-time evaluation of Go program source. It is > strictly a compiled language, although there are some (pieces of) > interpreters out there. > > -rob > > > On Mon, Mar 20, 2017 at 7:

Re: [go-nuts] []byte to func

2017-03-20 Thread Rob Pike
No, Go does not have run-time evaluation of Go program source. It is strictly a compiled language, although there are some (pieces of) interpreters out there. -rob On Mon, Mar 20, 2017 at 7:57 PM, Sandeep Kalra wrote: > Is there any option to convert []byte to func (Assuming that []byte > car

[go-nuts] []byte to func

2017-03-20 Thread Sandeep Kalra
Is there any option to convert []byte to func (Assuming that []byte carries valid function) package main import ( "fmt" "io/ioutil" ) func run(b []byte) { /// HERE ? } func main() { if b, e := ioutil.ReadFile("./file.go"); e != nil { fmt.Println(e) } else {