Hi Dean,

> I'm used to sprinkling print statements in my code as a way of tracking
> down bugs but they seem to be affecting my code more than I was expecting.

I recommend to look at 'trace' and 'msg'. They both output to stderr and don't
interfer with the expressions.

'trace' shows what argumments are passed, and what the functions return. See the
tutorial for examples.

'msg' prints its argument to stderr *and* returns it, so it does not destroy the
flow. For example:

   (if (condition)
      (doTrue)
      (doFalse1)
      (doFalse2) )

Now this would be wrong:

   (if (condition)
      (prinl "true")
      (doTrue)
      (doFalse1)
      (doFalse2) )

But this is all right:

   (if (msg (condition) " condition")
      (msg (doTrue) " true")
      (msm (doFalse1) " false")
      (doFalse2) )

Even easier is not to modify the source at all, and do instead, before starting
the program

   (mapc trace '(condition doTrue doFalse1))

And/or use 'debug' to single-trace your program. Again see the tutorial.


> I've also realised I'm never quite sure when and when I shouldn't precede a
> symbol with a quote e.g. as a function argument in a (debug 'Symbol)
> statement and wonder if there are some very simple rules of thumb.

It is noted in the reference. If an argument is noted as eg. 'any it means that
the argument is *evaluated* (not necessarily that you actually need to write a
quote).

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to