I found a way to include a "using" command inside a function without the 
Requires.jl package or needing to qualify the "new" package functions' 
names with a prefix. It is an easy way to achieve a "lazymode" effect. So I 
am sharing in case someone is interested.

As example, inside the function I mentioned initially (fwhm, which 
estimates the full width at half maximum of a noisy peak), instead of 
adding:

   if dodraw
      using Gadfly
   end

(which errors), I add the line:

   dodraw && eval(parse("using Gadfly"))

To my surprise, this works for me. Of course the first time fwhm(..., 
dodraw = true) is called, the function has an overhead wait while loading 
the Gadfly package. But the next times it is fast.

And inside the function I do not need to be writing Gadfly.plot(...) or 
gadfly().plot(...), etc.; plot(...) just works.

I am sure this must be a terrible hack in some ways I don't know and very 
bad Julian manners in general for reasons I ignore. Or maybe this would not 
have worked in v.0.3. But in v.0.4 it just does the trick for me. When I 
call fwhm(...,dodraw=true) I am normally not so interested in performance; 
and if I want it fast I do dodraw=false and the command eval(parse("using 
Gadfly")) is not even executed.

Reply via email to