[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Trace facility

From: Alex Shinn
Subject: Re: [Chicken-users] Trace facility
Date: Thu, 06 Jan 2005 01:27:07 -0600
User-agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI)

At Thu, 6 Jan 2005 01:35:23 +0000, Joel Reymont wrote:
> What's a good way to implement a tracing facility? Something where I
> could print messages to stdout but disable the printing by setting a
> variable. 
> Is there's a way to eliminate (compile out) the trace code when building
> a release?

You can conditionally run code based on features specified via the
-feature command (usable in both the interpreter and compiler):

      (define-macro (debug . args)
        `(fprintf (current-error-port) ,@args)))
      (define-macro (debug . args) #t)))

The macro makes sure the args are not evaluated so there is zero
overhead when not using "-feature debug".

If using low-level macros then this can also be done with environment
variables instead of features.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]