I would start with http://strangelyconsistent.org/blog/macros-what-are-they-really for a way to parse but not execute potentially expensive debug code.
On Sun, Dec 15, 2013 at 10:49 PM, Richard Hainsworth <rnhainswo...@gmail.com > wrote: > What should be the perl6 idiom for handling debug code? > > I am writing a program that will be run with large values and take some > time when it is clear that it is running correctly. > > In order to ensure that the program is correct, I have added code to > generate and output intermediate results. I do not want this code to be > compiled for the large values. At the same time, I don't want to eliminate > the code in case the intermediate results will be needed again. I have > previously handled this situation by commenting out the debug code, but > this leads to problems when I want it back. > > My first thought was: > > constant DEBUG = True; > > BEGIN { if DEBUG { > # code generating intermediate results > } > } > > But then this fails in this context > > class A { > has $.a is rw; > BEGIN { if DEBUG { > has @.mem-metric; > } > } > has $.b; > # etc etc etc > > method reset { > @.mem-metric = () > } > } > > I actually got " Null PMC access in find_method('mem-metric') " > without a line number to indicate at what point the compilation got > stopped, which indicates that this is a bug rather than a syntax error. > > However, I was wondering whether there was another way to achieve the same > effect. Possible using POD as an extension of just commenting out the code? > > Regards > Richard > > -- Will "Coke" Coleda