I noticed that the function generated by
eval is always a global function, making the code silly if I would like to generate some function defined in string. Are there any other ways to do something like this while avoid using
eval? Examples are:
function foo() return eval(parse("x->x")) end foo()(1) # ERROR: MethodError: no method matching (::##9#10)(::Int64) # The applicable method may be too new: # running in world age 21870, while current world is 21871. function foo() return x->x end foo()(1) # works fine
By the way I noticed there is a question mentioned this problem but no useful solution there.