[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: Inline `ifdef style` debugging
From: |
Roger |
Subject: |
Re: Re: Inline `ifdef style` debugging |
Date: |
Thu, 11 Aug 2011 02:40:24 -0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
> On Thu, Aug 11, 2011 at 12:23:00AM -0700, pjodrr wrote:
>Hello,
>
>Am Montag, 8. August 2011 19:20:25 UTC+2 schrieb Steven W. Orr:
>>
>> if (( debug ))
>> then
>> _debug()
>> {
>> "$@"
>> # I do question whether this is a viable construct, versus
>> # eval "$@"
>> }
>> else
>> _debug()
>> {
>> :
>> }
>> fi
>>
>
>on bash-hackers.org I found this, which I think is the ultimate
>method to write a debug-function:
>
>_debug() {
> if $whatever_test_you_prefer; then
> _debug() {
> "$@"
> }
> else
> _debug() {
> :
> }
> fi
> _debug "$@"
>}
>
>they call it "collapsing functions":
>http://wiki.bash-hackers.org/howto/collapsing_functions
Just a quick response here, "ifdef style" is C code not compiled into the
compiled program if it is not defined or chosen to be enabled. This in turn,
prevents the CPU from wasting cycles testing if/then statements, etc...
Tracing your suggestion, again, functions are read in each time the script is
run
even if debug=0, wasting CPU cycles & memory. (Please correct me if I'm wrong
here.)
Think the previous one or two examples did seem to closely as possible
mimic/copy
ifdef style.
The link looks interesting though, think I'll check it out!
--
Roger
http://rogerx.freeshell.org/
- Inline `ifdef style` debugging, Roger, 2011/08/08
- Re: Inline `ifdef style` debugging, Andreas Schwab, 2011/08/08
- Re: Inline `ifdef style` debugging, Dennis Williamson, 2011/08/08
- Re: Inline `ifdef style` debugging, Roger, 2011/08/08
- Re: Inline `ifdef style` debugging, Steven W. Orr, 2011/08/08
- Re: Inline `ifdef style` debugging, Roger, 2011/08/08
- Who's the target? Was: Inline `ifdef style` debugging, Steven W. Orr, 2011/08/08
- Re: Who's the target? Was: Inline `ifdef style` debugging, Roger, 2011/08/08
- Re: Who's the target? Was: Inline `ifdef style` debugging, Roger, 2011/08/09
- Message not available
- Aw: Re: Inline `ifdef style` debugging, pjodrr, 2011/08/11
- Re: Re: Inline `ifdef style` debugging,
Roger <=
- Re: Re: Inline `ifdef style` debugging, Greg Wooledge, 2011/08/11
- Re: Re: Inline `ifdef style` debugging, Roger, 2011/08/11
- Re: Re: Inline `ifdef style` debugging, Greg Wooledge, 2011/08/11
- Message not available
- Aw: Re: Re: Inline `ifdef style` debugging, pjodrr, 2011/08/11
- Message not available
- Aw: Re: Re: Inline `ifdef style` debugging, pjodrr, 2011/08/11