Re: [julia-users] use macros like a preprocessor directive?

2016-10-25 Thread Steven G. Johnson
You can use @static to implement a parse-time conditional

Re: [julia-users] use macros like a preprocessor directive?

2016-10-24 Thread Mauro
Maybe something like this: file pre.jl: if !isdefined(:proc) proc = false end module A macro pre(ex) if Main.proc return ex else :(println("doing nothing")) end end function f(x) @pre sort!(x) x end end v = rand(5) A.f(v) @show v Then use it with: $

Re: [julia-users] use macros like a preprocessor directive?

2016-10-24 Thread Florian Oswald
Ok. any suggestions how to get close to the C preprocessor behaviour though? On Monday, 24 October 2016 11:13:18 UTC+2, Mauro wrote: > > On Mon, 2016-10-24 at 10:37, Florian Oswald > wrote: > > I have something that this in C++ I would write like > > > > double f(double x){ > > // do som

Re: [julia-users] use macros like a preprocessor directive?

2016-10-24 Thread Mauro
On Mon, 2016-10-24 at 10:37, Florian Oswald wrote: > I have something that this in C++ I would write like > > double f(double x){ > // do something with x > #ifdef MACROVAR > // do something else with x > #endif > return(x) > } > > I was trying to understand how i could use julia ma

[julia-users] use macros like a preprocessor directive?

2016-10-24 Thread Florian Oswald
I have something that this in C++ I would write like double f(double x){ // do something with x #ifdef MACROVAR // do something else with x #endif return(x) } I was trying to understand how i could use julia macro's to achieve something similar. I have seen how the Logging.jl u