Open BryantLam opened 5 years ago
I don't think this works. My goal was to emulate something like Rust's dbg
macro, but printing the filename or line number doesn't make sense because those Reflection
functions are called inside the dbg
procedure instead of at the callsite of dbg
.
@BryantLam - can you say more about why you want something like this? Is it just for debugging?
This specific feature request is to help with debugging. The Chapel project could provide a compiler-assisted function to implement a dbg
macro and I'd be satisfied.
What's the current stance on having a macro system in Chapel? Macros would enable things like abstracting boilerplate based on an operator, though a functional approach #14153 works without macros.
Java doesn't have macros and I don't know whether they just live without them or if they do something else (I think an IDE like Eclipse can extract from the Java bytecode the expression to print during a debug session, but I'm just guessing; it's been a while since I used Eclipse). You could just abuse the C preprocessor if really needed...
This issue initially started out as a request for a macro system, but I think most of the functionality I would want is (mostly) resolved with the
Reflection
module. That said, macros would still be nice for reducing code boilerplate.Anyway, there's no way to do the following today that I'm aware of.
This could be added to the
Reflection
module (but maybeReflection
should serve as inspiration for a macro system in the long term).Note that this is only useful if it can be composed, which seems problematic: