On Wed, 25 Feb 2004 15:09:03 +0100, Robert Klemme wrote:

> 
> "Simon Strandgaard" <neoneye / adslhome.dk> schrieb im Newsbeitrag
> news:pan.2004.02.25.13.47.23.98604 / adslhome.dk...
>> On Wed, 25 Feb 2004 14:26:36 +0100, Robert Klemme wrote:
>> > "Simon Strandgaard" <neoneye / adslhome.dk> schrieb im Newsbeitrag
>> >> Its syntax is
>> >>
>> >>     debug :method [, :method]*
>> >>
>> >> What it does is to enable the global flag $debug.
>> >
>> > More precisely it switches all output on or off in a method.  And
> that's
>> > what I don't like about it: in your example class A behavior of
> "puts",
>> > "print" etc. changes depending on the $debug flag.  That's IMHO not
>> > compliant with POLS.
>>
>> Agree it isn't POLS, but debugging is sometimes tuff.
> 
> Taff?  Well, yes it is.

First I tried with 'toff' but it looked wrong ;-)

 
>> I never remove print statements.. because I one day might need that
>> information. Then a debug keyword + Debuggable module is practical.
>> I have attached a debug output from a testcase (my regexp project).
>>
>> I have used logfiles in the past.. but in conjunction with
>> unittesting they seems to be not needed.
>>
>>
>> > I'd prefer to have specialized methods for debug printing.
>> >
>>
>> Please enlighten me.  How do you debug ?
> 
> ?  Sorry if I wasn't clear enough.  The thing I don't like is the naming
> of the methods used for debug printing.  I mean, rather use different
> names than "puts", "print" etc. in order to be able to have regular output
> as well as debug output.  Also it helps in identifying lines that can be
> taken out once the code is ok.  (Ok, you don't take them out so this
> argument doesn't count for you - but other IMHO.)

Understandable.. using puts, print has drawbacks.  Good suggestion, I
think I will replace them with something else. 

Any ideas for a good name?

debug replacement puts  ->  #debug_puts,  #dputs
debug replacement p     ->  #debug_p,     #dp

maybe just turn the 'p' in 'puts' upsidedown, so it becomes a 'd' => duts?

 
> Is there a reason why your debug output methods need to override methods
> defined in Kernel?
> 

do you mean 'class Module'?

Yes there is a good reason.. by having it here, allows me to use 
the debug keyword inside modules. Like this:

	module TodoVerbose
		include MatchVerbose
		debug :test_verbose_alt_rep1
		#undef test_verbose_alt_rep1
		#debug :test_verbose_alt_rep2
		undef test_verbose_alt_rep2
		#debug :test_verbose_repeat1
		undef test_verbose_repeat1
		#debug :test_verbose_repeat2
		undef test_verbose_repeat2
		debug :test_verbose_repeat3
		undef test_verbose_repeat3
	end

If the 'debug' keyword was defined in class Object, then
above wouldn't be possible.


>> It would be nice to identify a good model for advanced debugging with
>> Test::Unit.
> 
> Yeah.
> 

Agree ;-)

--
Simon Strandgaard