On Sun, Aug 26, 2012 at 12:35 PM, RoboTamer <
grue...@gmail.com> wrote:
> I am working on a function exists, is function function.
> Seams I am almost there, but I can't figure out how to replace main in
> ValueOf(main) with a variable.
> I tried Unquote with no success.
> You can test what I have so far at the play.go
Go doesn't allow this because there are certain advantages to disallowing it.
1. The compiler can identify and remove code that will never be called
at compile time, reducing the size of the executable.
2. You can remove code from your code base and know at compile time
whether or not that code could ever be called at runtime. Making it
easier to refactor code.
If Go allowed you to convert a string in to a function pointer then we
would lose the two advantages above. It's a trade off.
It's common when coming to a new programming language to just keep
trying to write code like you've done in another language. Each
language is different and requires a different approach. If you're
trying to do this in Go then it's likely your coming at your problem
from the perspective of a dynamically typing language programmer and
you should rethink how you'd design your program.
--
=====================
http://jessta.id.au