Many thanks!
I have a similar problem calling a function in following scenario:
function tst3(i::Int)
println(i)
end
macro tst(i::Int)
tst3(i)
end
I obtain an error executing code:
julia> b = 2::Int
julia> @tst b
complaining for a problem of type, because tst3 seems to receive a
Symbol instead an Integer:
ERROR: TypeError: anonymous: in typeassert, expected Int64, got Symbol
What is correct form in this case?
Leonardo
Il 27/09/2015 18:58, Yichao Yu ha scritto:
On Sun, Sep 27, 2015 at 12:20 PM, Leonardo <[email protected]> wrote:
Hi all,
I need manipulate AST of an expression in a macro, and pass same expression
in input to another macro, but I experience some problem.
I try to express my doubt with a simplified example:
macro tst2(e2::Expr)
println(e2.head)
end
macro tst(e1::Expr)
@tst2 esc(e1)
end
```
macro tst(e1::Expr)
quote
@tst2 $(esc(e1))
end
end
```
otherwise, `@tst2` will be run at `tst` definition time.
In previous code I want that call to @tst2 behave exact like call to @tst.
E.g. calling @tst2 in REPL I obtain:
julia> a = 2
julia> @tst2(a < 3)
comparison
but same call to @tst has no effect, and I cannot find an alternative
working form for @tst
Someone can help me to understand this odd behaviour of Julia's macro?
Many thanks in advance
Leonardo