On Thursday, June 26, 2014 11:57:14 PM UTC+2, Tomas Lycken wrote:

> Just to be clear: I’m aware that there’s probably no way to get this 
> working with e.g. any string variable. But I don’t see a reason why it 
> shouldn’t be possible when passing a constant, or especially a literal 
> constant, to the macro, such as with @foo("bar") (rather than bar="bar"; 
> @foo(bar), which I understand might be impossible). 
>
This works with string literals:

macro include(file)
    esc(parse(open(readall, file)))
end

function testinclude() foo = "foo" println(foo) @include("includetest2.jl") 
end
testinclude()

It prints "foo" twice.

Reply via email to