Please do work through the examples in the Metaprogramming section of the manual to learn how to take apart and reassemble expressions to do what you need:
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/ There are tools (such as `macroexpand`) introduced in the manual that will help you debug this kind of issue. In general, when asking questions on the list, please: - search for previous discussions (such as this one: https://groups.google.com/forum/#!searchin/julia-users/type$20macro/julia-users/r9sGn-k7SDw/Xm0nKsKBBJYJ ) - provide a complete example. "this is what i am doing in the macro" does not provide enough context. Thanks! On Tue, Oct 20, 2015 at 3:02 PM, <[email protected]> wrote: > Hi fellows, > > Question 1: > > I am trying to generate a type in a macro and expect to see it in the > calling context. > this is what i am doing in the macro: > code = quote eval(parse(string("type ", $(priv_typname), " end"))) end > > here is what is returned from the macro > eval(parse(string("type ",$(Expr(:escape, "priv_Eq"))," end"))) > > but in the julia shell, when i try to do this : > > julia> a = priv_Eq() > ERROR: UndefVarError: priv_Eq not defined > > can somebody tell me why and what I am doing wrong? > > > Question 2: > > I am also trying to generate a parametrized type like: > > type Eq{T,S} > end > > any suggestions to append the type_params to the type programmatically? > > Thanks > > > > > >
