Hi,

I would like to create an @invisible macro that takes statements and
appends `nothing` at the end. The motivation is to provide something
similar to invisible() in R, if not in implementation then in
functionality, especially because when I am using Gadfly then printing
the plots opens them in the browser and something this is not what I
want (but this is also a good opportunity for the to learn about macros
in Julia, regardless of the application).

So

@invisible(p1=plot(x=x1, y=y1), p2=plot(x=x2, y=y2))

would expand to

begin
  p1=plot(x=x1, y=y1)
  p2=plot(x=x2, y=y2)
  nothing
end

A Common Lisp implementation would be something like

(defmacro invisible (&body body)
  `(progn ,@body nil))

so I tried

macro invisible(expressions...)
  quote
    $(expressions...)
    nothing
  end
end

which I thought works fine because

julia> macroexpand(:(@invisible(a=1)))
quote  # none, line 3:
    a=1 # line 4:
    nothing
end

but then I get an error message:

julia> @invisible(a=1)
ERROR: unsupported or misplaced expression kw

so obviously I am not getting something, can someone please help me out?

Also, is there a tutorial or guide on Julia macros that is written for
those familiar with the LISP family, so that I could map concepts in the
two languages?

Best,

Tamas

Reply via email to