You can use @static to implement a parse-time conditional
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:
$
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
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
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