Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 3739 days ago | link | parent

I finally installed Julia, and my comment needs a correction. Macros sometimes don't need the parens.

  julia> macro foo(ex)
	   :($ex ? nothing : error("Assertion failed: ", $(string(ex))))
	 end

  julia> @foo 2 > 0

  julia> @foo 2 > 3
  ERROR: Assertion failed: :((2>3))
   in error at error.jl:22
However, I have not been able to get this to work with multiple args:

  julia> macro foo(ex, msg)
	   :($ex ? nothing : error("$($msg): ", $(string(ex))))
	 end

  julia> @foo(2 > 3, "aaa")
  ERROR: aaa: :((2>3))
   in error at error.jl:22

  julia> @foo 2 > 3, "aaa"
  ERROR: wrong number of arguments
I don't know if this is a real limitation, or I just don't know enough yet.