picrin
picrin copied to clipboard
Debug print reader macro
In Gauche, there is debug print reader macro #?=, expanded with following expression to (debug-print expr). It is useful for printf debugging.
AIU there does not seem be user reader macro in picrin. Is it easy to implement it?
@kenoss
In Gauche, there is debug print reader macro #?=
I definitely agree to this idea. But the literal itself is something we need to discuss further.
IMO, #? is better than #?=. Ideas? @zeptometer @KeenS @stibear @koba-e964
AIU there does not seem be user reader macro in picrin. Is it easy to implement it?
If we decided to implement it as a language embedded functionality, that's not so difficult. If you want to do from the user end level, which means that you make the reader function in scheme, another printing function will be necessary. The normal write function can evaluate user code in order to format record objects. This behavior might be harmful at debug time (what if the record writer triggers modifications to file system? Debug printer should not affect to the execution context, shouldn't it?).
I'm for #?=, or I'd like #? to be debugging functionality dispatcher. Other debugging functionalites I caught up for now are max call stack depth, execution time, memory usage, macro expanded form and so on.
I know implementing some of these is challenging but extensibility is needed.
@KeenS
I might think of similar thing. You mean #? debug-print expr should expanded to (debug-print expr), don't you. Same thing will be done with editor's help, but this general reader macro will be even useful since we can easily make it on/off by comment out the separated line consisting of #? debug-print.
It maybe useful to support macros with fixed argument length like (debug-something arg1 arg2 expr) and macros with indefinite number of keyword parameters and one expression like (debug-something :foo arg1 :bar arg2 expr). (There's no benefit to debug keywords.) However I'm not confident the latter is useful. From the implementing view point, it maybe good to restrict let-like two arguments macros.
Of course I do not mean we can support functionalities you listed with usual Scheme/legacy macros. An example we can is stub or dummy variable by inserting let. Is it confusing to mix functionalities implemented with/without macros?
Sometimes I wanted "debug-print-recursively" to watch all arguments and return values (like trace but using trace pays attension to one function, it does to part of source code). We can support simple version of this with Scheme macro.