You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some code where I want to use Calculus.jl to differentiate symbolic expressions inside a @generated function. This currently does not work because after differentiating Calculus.jl calls simplify, which in turn often ends up calling eval. As of right now @generated functions are not allowed to call eval.
I'm opening this issue to see if those who know the internals here better think it would be possible/feasible to remove the call to eval inside simplify?
I had exactly the same issue today. Looking in the symbolic.jl I saw that it was only used for doing arithmetics. Thus replaced eval with a following code
if all(isnumber, ex.args[2:end]) && length(ex.args) > 1
### Doing numerical stuff!!!
################ A Patch Here #################
op = ex.args[1]
nums = ex.args[2:end]
if op==:+
return +(nums...)
elseif op==:-
return -(nums...)
elseif op==:/
return /(nums...)
elseif op==:*
return *(nums...)
else
error("Operation $op not implemented")
end
############# Replaces ######################
#return eval(current_module(), ex)
#############################################
end
I have some code where I want to use Calculus.jl to differentiate symbolic expressions inside a
@generated
function. This currently does not work because after differentiating Calculus.jl callssimplify
, which in turn often ends up callingeval
. As of right now@generated
functions are not allowed to call eval.I'm opening this issue to see if those who know the internals here better think it would be possible/feasible to remove the call to
eval
insidesimplify
?ref: EconForge/Dolang.jl#31 (comment)
The text was updated successfully, but these errors were encountered: