3

I'm trying to use the guile function trace, but every time I do, I get a possible unbound variable.

scheme@(guile-user)> (define (fact1 n)
(if (zero? n) 1
(* n (fact1 (- n 1)))))
scheme@(guile-user)> (trace fact1)
;;; <stdin>:4:0: warning: possibly unbound variable `trace'
<unnamed port>:4:0: In procedure #<procedure 10e4080c0 at <current input>:4:0 ()>:
<unnamed port>:4:0: In procedure module-lookup: Unbound variable: trace

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 

I was wondering if anyone knows why this is not working.

AmaCode
  • 143
  • 1
  • 7
  • Guile does not have a `trace` function included by default. It seems the [`(ice-9 debug)`](https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Tracing.html) module includes one, though. Where did you see something that led you to believe `trace` would work in Guile? – Alexis King Nov 17 '16 at 00:05
  • My instructor gave us that example to work off of. – AmaCode Nov 17 '16 at 00:08
  • Ok, you probably need to use `(use-modules (ice-9 debug))` to import `trace` first. – Alexis King Nov 17 '16 at 00:10
  • I tried that and did the same thing as above and it still didn't work – AmaCode Nov 17 '16 at 00:13
  • An you got the same error message or something else? Please edit your post with new information if it changed. – Sylwester Nov 17 '16 at 12:45

1 Answers1

4

Use ,trace:

GNU Guile 2.0.12
Copyright (C) 1995-2016 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (define (fact1 n)
... (if (zero? n) 1
... (* n (fact1 (- n 1)))))
scheme@(guile-user)> ,trace (fact1 5)
trace: |  (#<procedure 110221480> #(#<directory (guile-user) 10f9fabd0> #f))
trace: |  #(#<directory (guile-user) 10f9fabd0> fact1)
trace: (#<procedure 11022e1e0 at <current input>:2:0 ()>)
trace: (fact1 5)
trace: |  (fact1 4)
trace: |  |  (fact1 3)
trace: |  |  |  (fact1 2)
trace: |  |  |  |  (fact1 1)
trace: |  |  |  |  |  (fact1 0)
trace: |  |  |  |  |  1
trace: |  |  |  |  1
trace: |  |  |  2
trace: |  |  6
trace: |  24
trace: 120
uselpa
  • 18,732
  • 2
  • 34
  • 52