if you look at macroexpand, you may be able to spot the difference quickly.

in short, `@printf` generates code to make a string from it's arguments.
whereas you are simply making a string from the arguments.

On Fri Jan 23 2015 at 10:19:49 PM Kirill Ignatiev <[email protected]>
wrote:

> With this macro:
>
> macro test(fun)
>   @printf "%s\n" string(fun)
> end
>
> these three expressions print as follows:
>
> @test(sin)
> # sin
> @test(x -> sin(x))
> # x->begin  # /***.jl, line 84:
> #        sin(x)
> #    end
> @printf "%s\n" string(x -> sin(x))
> # (anonymous function)
>
> How do I get the string "(anonymous function)" inside a macro with the
> string function? It keeps expanding fun to the whole function expression,
> which I don't want to print in full.
>

Reply via email to