Debug Print Macro
The @dprint macro is used during debugging to print both the text form of an expression and its evaluated result. For example, @dprint(x + y) would output x + y = 5, clearly showing the correspondence between the expression and its value.
This functionality cannot be achieved with ordinary functions. Functions can only receive computed values and cannot access the original source code text. Macros can do this because they work at compile time and have access to the source code token sequence, capturing the expression as a string through input.toString().
The code below simulates the effect of @dprint. Although no actual macro is defined, it demonstrates the form of the code generated after macro expansion. The macro expands @dprint(x + y) into two lines of code: first printing the expression text, then printing the computed result.
This debugging technique is very practical in real development, allowing you to quickly check the state of multiple variables. Try modifying the expressions and observe how the output changes.