Optional argument in macro

I suggest looking at @less Threads.@threads :static for i in 1:10 end for inspiration. It’s defined macro threads(args...) and then sorts out which arguments are options and which content.

I wouldn’t. Another common pattern is macro trainprogress(ex...); _ trainprogress(ex...) |> esc; end. Now _trainprogress is an ordinary function, taking and returning expressions. And you can happily write 2- and 3-arg versions of this function which call each other, if you want.

2 Likes