@isuruf I'm looking for "Efficient Equation of Motion Generation", project, and I wanted to discuss the amount of time that implementing wrappers (in python)would require(I choose for around 2 weeks, after considering the wrappers implemented for other functions till now)

@bhavishyagopesh, I'm not sure what there is to be done in that project. Did you talk to @moorepants about it?

@isuruf ok

@isuruf this is with reference to symengine/symengine#1225. Actually there was a typo, I used the

`exp()`

function in pow.cpp, and on running `exp(2)`

I got an answer of 7.38906. Please tell me how to reproduce the error or which files I should refer to for the above issue.
Can you post your source code?

Sure,

```
#include <iostream>
#include <limits>
#include <symengine/basic.h>
#include <symengine/symbol.h>
#include <symengine/dict.h>
#include <symengine/integer.h>
#include <symengine/pow.h>
#include <symengine/printer.h>
using SymEngine::Basic;
using SymEngine::Mul;
using SymEngine::Pow;
using SymEngine::Symbol;
using SymEngine::symbol;
using SymEngine::umap_basic_num;
using SymEngine::map_vec_int;
using SymEngine::Integer;
using SymEngine::integer;
using SymEngine::multinomial_coefficients;
using SymEngine::RCP;
using SymEngine::rcp_dynamic_cast;
int main(){
RCP<const Basic> e, f, r;
std::cout<<exp(2) ;
return 0 ;
}
```

The expressions e, f, r play no role in the code.....

that's the function from C stdlib

`std::cout << *exp(integer(2))`

Ok, but wouldn't

`using Symengine::Pow`

automatically use the `exp()`

from pow.cpp or should I specify the namespace also ?
you need to use

`using SymEngine::exp`

```
function expr_arr_to_block(exprs)
block = :(begin end)
foreach(expr -> push!(block.args, expr), exprs)
block
end
macro build_ops()
exprs = Vector{Expr}(0)
for (op, libnm) in ((:+, :add), (:-, :sub), (:*, :mul), (:/, :div), (://, :div), (:^, :pow))
tup = (Base.Symbol("basic_$libnm"), libsymengine)
function ($op)(b1::Basic, b2::Basic)
a = Basic()
ccall($tup, Void, (Ptr{Basic}, Ptr{Basic}, Ptr{Basic}), &a, &b1, &b2)
return a
end
push!(exprs,:(($op)(b1::BasicType, b2::BasicType) = ($op)(Basic(b1), Basic(b2))))
end
expr_arr_to_block(exprs)
end
@build_ops
```

I think that should work in place of the

`@eval`

s?
Are

`@evals`

that are run on pre-compilation stage a problem?
I thought only the ones run on

`__init__`

are an issue
not sure

but it's probably best to get rid of them anyways

why?

```
macro build_ops()
exprs = Vector{Expr}(0)
for (op, libnm) in ((:+, :add), (:-, :sub), (:*, :mul), (:/, :div), (://, :div), (:^, :pow))
tup = (Base.Symbol("basic_$libnm"), libsymengine)
ex = :(
function ($op)(b1::Basic, b2::Basic)
a = Basic()
ccall($tup, Void, (Ptr{Basic}, Ptr{Basic}, Ptr{Basic}), &a, &b1, &b2)
return a
end
($op)(b1::BasicType, b2::BasicType) = ($op)(Basic(b1), Basic(b2))
)
push!(exprs,ex)
end
expr_arr_to_block(exprs)
end
```

might be this

I haven't had any problems with

`@eval`

creating functions, for example, in a for loop etc. within a module, but I've not ever had it work correctly when in a function, `__init__`

or otherwise.
well, first of all it gets rid of the warning

@ScottPJones

`@eval`

works at the module scope, so if you generate variables you have to bring the global that it creates back into scope
Secondly, I am not sure if that kind of

`@eval`

will still allow static compilation :smile:
I'm not worried about static compilation, but we do depend on precompilation a lot.

Yes, I hadn't thought of that, when extending a method. Not sure how I'd to it though (bring it into the correct scope)

```
function test_eval()
@eval :(a=2)
global a
println(a)
end
```

More stuff like that here: https://github.com/ChrisRackauckas/ParallelDataTransfer.jl#performance-note

but yeah, my main thing is, @isuruf that warning is scary :smile:

I was making a scheme to decouple our many service modules, that want to define serialization/deserialization functions for their own types, that the central serializer/deserializer code can dispatch on.

I'd like to get rid of it before tagging a release that allows precompilation

@ChrisRackauckas, yes. that warning is for

`init_constants`

method right?
Yes, I know how to deal with globals with eval, just hadn't thought I'd have to do something when extending a function - but I guess maybe it wasn't extending it, it was making a local function.

```
using ParameterizedFunctions
INFO: Recompiling stale cache file /home/crackauc/.julia/lib/v0.5/ParameterizedFunctions.ji for module ParameterizedFunctions.
WARNING: eval from module SymEngine to ParameterizedFunctions:
Expr(:block, Expr(:line, 60, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, Expr(:tuple, :basic_new_stack, :libsymengine)::Any, :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :IM)::Any)::Any, Expr(:line, 61, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, (:basic_const_I, "/home/crackauc/.julia/v0.5/SymEngine/deps/usr/lib/libsymengine.so"), :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :IM)::Any)::Any, Expr(:line, 62, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:call, :finalizer, :IM, :basic_free)::Any)::Any
** incremental compilation may be broken for this module **
WARNING: eval from module SymEngine to ParameterizedFunctions:
Expr(:block, Expr(:line, 60, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, Expr(:tuple, :basic_new_stack, :libsymengine)::Any, :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :PI)::Any)::Any, Expr(:line, 61, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, (:basic_const_pi, "/home/crackauc/.julia/v0.5/SymEngine/deps/usr/lib/libsymengine.so"), :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :PI)::Any)::Any, Expr(:line, 62, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:call, :finalizer, :PI, :basic_free)::Any)::Any
** incremental compilation may be broken for this module **
WARNING: eval from module SymEngine to ParameterizedFunctions:
Expr(:block, Expr(:line, 60, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, Expr(:tuple, :basic_new_stack, :libsymengine)::Any, :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :E)::Any)::Any, Expr(:line, 61, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, (:basic_const_E, "/home/crackauc/.julia/v0.5/SymEngine/deps/usr/lib/libsymengine.so"), :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :E)::Any)::Any, Expr(:line, 62, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:call, :finalizer, :E, :basic_free)::Any)::Any
** incremental compilation may be broken for this module **
WARNING: eval from module SymEngine to ParameterizedFunctions:
Expr(:block, Expr(:line, 60, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, Expr(:tuple, :basic_new_stack, :libsymengine)::Any, :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :EulerGamma)::Any)::Any, Expr(:line, 61, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:ccall, (:basic_const_EulerGamma, "/home/crackauc/.julia/v0.5/SymEngine/deps/usr/lib/libsymengine.so"), :Void, Expr(:tuple, Expr(:curly, :Ptr, :Basic)::Any)::Any, Expr(:&, :EulerGamma)::Any)::Any, Expr(:line, 62, :/home/crackauc/.julia/v0.5/SymEngine/src/mathops.jl)::Any, Expr(:call, :finalizer, :EulerGamma, :basic_free)::Any)::Any
** incremental compilation may be broken for this module **
```

Yechhh!

I guess it may just be the constants?

yes. I'll implement it for the constants for now. There are lots of @evals but only the constants are given issues

I've tried the following,

```
macro init_constant(op, libnm)
tup = (Base.Symbol("basic_const_$libnm"), libsymengine)
alloc_tup = (:basic_new_stack, libsymengine)
:(
ccall($alloc_tup, Void, (Ptr{Basic}, ), &($op))
ccall($tup, Void, (Ptr{Basic}, ), &($op))
finalizer($op, basic_free)
)
end
function init_constants()
@init_constant IM I
@init_constant PI pi
@init_constant E E
@init_constant EulerGamma EulerGamma
end
```

doesn't work

btw

you probably shouldn't overwrite Julia's

`I`

Yes, that's why

`IM`

is used
oh I see

it's the other way around

do you need to escape the values?

got it. needs a

`begin`

and an `end`

for multiple statements
Can you check that https://gist.github.com/isuruf/4fcb76eaf27daa820bc7b9d1c7a0df50 works?

symengine/SymEngine.jl#78