In Julia, why is @printf a macro instead of a function?

前端 未结 2 1375
春和景丽
春和景丽 2020-12-29 02:11

In Julia, the syntax to print a formatted string is as follows:

@printf(\"Hello %d\\n\", 5)

Why is @printf a macro instead of

2条回答
  •  孤独总比滥情好
    2020-12-29 02:48

    It is for performance. The printf macro takes a constant format string (eg. "Hello %d\n") and generates optimized code for that string.

提交回复
热议问题