Hi gophers,
I was studying runtime code generation and was wondering if there's a way to generate a function at runtime.
Let's say we have a function: fun(a,b) {return a+b}
This function is parsed to our program as a string, parsed and compiled to a function in go.
In C# and java you can do this as you have access to the clr and jvm which can jit compile your function for you.
Now go is a statically compiled language and as far as I can see the reflect package is not powerful enough for such operations.
Are my assumptions correct that this is not currently possible?
Could it be done through cgo? (If yes a hint to c documentation would be nice :) )
Would it be possible in go in the future?
Creative ideas are welcome but prefer portable solutions so no assembly generation through c or such :)
For performance reasons it wouldn't be beneficial to have a. Net runtime running that you sent a million requests to.
Kind regards,
Jzs.
Thanks kevin,
I appreciate the answer :)
As long asgo marks memory pages as noexec then I'm out of luck. I am not proposing to mark all memory pages as executable as this would clearly be a bad idea.
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi gophers,
I was studying runtime code generation and was wondering if there's a way to generate a function at runtime.
Let's say we have a function: fun(a,b) {return a+b}
This function is parsed to our program as a string, parsed and compiled to a function in go.