Re: [racket-users] trace facility in Racket?
Right, sorry, I should have added… doing *that* (eliminating the traces for production code) is almost trivial: just make a macro that’s defined to disappear when a flag is set: #lang racket (define-for-syntax production-flag #f) (define-syntax (debug-only stx) (syntax-case stx () [(_ expr) (if production-flag #'(void) #'expr)])) (define (fact f) (if (= f 0) 1 (begin (debug-only (printf "hello!\n")) (* f (fact (- f 1)) (fact 6) The hard part is building UI tools to manipulate and insert these things without any changes to the code at all. John > On Mar 21, 2020, at 11:36 AM, Nicholas Papadonis > wrote: > > Thanks, you answered my question. I’m educating myself in ways to debug > Scheme, coming from an imperative background. > > I suspect the solution would be to leave the trace statements in and use a > conditional when delivering production code. > > >> On Mar 21, 2020, at 2:27 PM, John Clements wrote: >> >> It sounds like you’re looking for a way to have the trace inserted for you >> by a debugging tool, so you don’t have to remember to take it out again >> later. This wouldn’t be hard to do, but (as far as I know) no one’s taken >> the time to do it. >> >> John >> >>> On Mar 21, 2020, at 8:43 AM, Nicholas Papadonis >>> wrote: >>> >>> I was successful with MIT Scheme placing (trace proc) inside the closure of >>> this code. Placing (trace proc) outside the closure did not have any >>> effect. >>> >>> This is the question I'm asking. Is it possible to trace without modifying >>> the closure? >>> >>> I ask due to forward thinking about software engineering practices and >>> modifying code (although it could be argued in C a preprocessor block could >>> be placed to compile in or out conditional macros blocks). >>> >>> Thanks again >>> >>> On Sat, Mar 21, 2020 at 11:24 AM Ben Greenman >>> wrote: >>> On 3/21/20, dgtlcmo wrote: Does anyone know how to trace functions inside a closure? I would like to trace hanoi-move, however find that with MIT Scheme I need to place (trace) within the closure (hanoi n), otherwise the trace will not occur. Can a trace like this be performed in Racket? Thanks (define (hanoi n) (define (pmd from to) (display "Move ") (display from) (display " to ") (display to) (newline) '()) (define (hanoi-move n from to spare) (cond ((= n 0) '()) ((= n 1) (pmd from to)) (else (hanoi-move (- n 1) from spare to) (hanoi-move 1 from to spare) (hanoi-move (- n 1) spare to from (hanoi-move n "A" "B" "C")) >>> >>> Yes, Racket has trace tools: >>> https://docs.racket-lang.org/reference/debugging.html >>> >>> Try adding (trace hanoi) before the call to (hanoi-move ) at the bottom >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Racket Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to racket-users+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/racket-users/CAKD0t1%2Bn_W7%3Dc7%3D_KAcFuJQrFo86JBx8uGJuBfXY%2BgZrDFKHWg%40mail.gmail.com. >> >> >> > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/fbf7ed4c-1373-495c-b951-575c3cf7e61f%40mtasv.net.
Re: [racket-users] trace facility in Racket?
Thanks, you answered my question. I’m educating myself in ways to debug Scheme, coming from an imperative background. I suspect the solution would be to leave the trace statements in and use a conditional when delivering production code. > On Mar 21, 2020, at 2:27 PM, John Clements wrote: > > It sounds like you’re looking for a way to have the trace inserted for you by > a debugging tool, so you don’t have to remember to take it out again later. > This wouldn’t be hard to do, but (as far as I know) no one’s taken the time > to do it. > > John > >> On Mar 21, 2020, at 8:43 AM, Nicholas Papadonis >> wrote: >> >> I was successful with MIT Scheme placing (trace proc) inside the closure of >> this code. Placing (trace proc) outside the closure did not have any effect. >> >> This is the question I'm asking. Is it possible to trace without modifying >> the closure? >> >> I ask due to forward thinking about software engineering practices and >> modifying code (although it could be argued in C a preprocessor block could >> be placed to compile in or out conditional macros blocks). >> >> Thanks again >> >> On Sat, Mar 21, 2020 at 11:24 AM Ben Greenman >> wrote: >> On 3/21/20, dgtlcmo wrote: >>> Does anyone know how to trace functions inside a closure? I would like to >>> trace hanoi-move, however find that with MIT Scheme I need to place (trace) >>> >>> within the closure (hanoi n), otherwise the trace will not occur. >>> >>> Can a trace like this be performed in Racket? >>> >>> Thanks >>> >>> (define (hanoi n) >>> (define (pmd from to) >>>(display "Move ") >>>(display from) >>>(display " to ") >>>(display to) >>>(newline) >>>'()) >>> (define (hanoi-move n from to spare) >>>(cond ((= n 0) '()) >>> ((= n 1) (pmd from to)) >>> (else >>> (hanoi-move (- n 1) from spare to) >>> (hanoi-move 1 from to spare) >>> (hanoi-move (- n 1) spare to from >>> (hanoi-move n "A" "B" "C")) >> >> Yes, Racket has trace tools: >> https://docs.racket-lang.org/reference/debugging.html >> >> Try adding (trace hanoi) before the call to (hanoi-move ) at the bottom >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to racket-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/racket-users/CAKD0t1%2Bn_W7%3Dc7%3D_KAcFuJQrFo86JBx8uGJuBfXY%2BgZrDFKHWg%40mail.gmail.com. > > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/38078F54-CD65-4223-852D-1D142C001F18%40gmail.com.
Re: [racket-users] trace facility in Racket?
It sounds like you’re looking for a way to have the trace inserted for you by a debugging tool, so you don’t have to remember to take it out again later. This wouldn’t be hard to do, but (as far as I know) no one’s taken the time to do it. John > On Mar 21, 2020, at 8:43 AM, Nicholas Papadonis > wrote: > > I was successful with MIT Scheme placing (trace proc) inside the closure of > this code. Placing (trace proc) outside the closure did not have any effect. > > This is the question I'm asking. Is it possible to trace without modifying > the closure? > > I ask due to forward thinking about software engineering practices and > modifying code (although it could be argued in C a preprocessor block could > be placed to compile in or out conditional macros blocks). > > Thanks again > > On Sat, Mar 21, 2020 at 11:24 AM Ben Greenman > wrote: > On 3/21/20, dgtlcmo wrote: > > Does anyone know how to trace functions inside a closure? I would like to > > trace hanoi-move, however find that with MIT Scheme I need to place (trace) > > > > within the closure (hanoi n), otherwise the trace will not occur. > > > > Can a trace like this be performed in Racket? > > > > Thanks > > > > (define (hanoi n) > > (define (pmd from to) > > (display "Move ") > > (display from) > > (display " to ") > > (display to) > > (newline) > > '()) > > (define (hanoi-move n from to spare) > > (cond ((= n 0) '()) > > ((= n 1) (pmd from to)) > > (else > > (hanoi-move (- n 1) from spare to) > > (hanoi-move 1 from to spare) > > (hanoi-move (- n 1) spare to from > > (hanoi-move n "A" "B" "C")) > > Yes, Racket has trace tools: > https://docs.racket-lang.org/reference/debugging.html > > Try adding (trace hanoi) before the call to (hanoi-move ) at the bottom > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/CAKD0t1%2Bn_W7%3Dc7%3D_KAcFuJQrFo86JBx8uGJuBfXY%2BgZrDFKHWg%40mail.gmail.com. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/9c7a5a9d-c664-4dfe-8d86-02958035baa4%40mtasv.net.
Re: [racket-users] trace facility in Racket?
I was successful with MIT Scheme placing (trace proc) inside the closure of this code. Placing (trace proc) outside the closure did not have any effect. This is the question I'm asking. Is it possible to trace without modifying the closure? I ask due to forward thinking about software engineering practices and modifying code (although it could be argued in C a preprocessor block could be placed to compile in or out conditional macros blocks). Thanks again On Sat, Mar 21, 2020 at 11:24 AM Ben Greenman wrote: > On 3/21/20, dgtlcmo wrote: > > Does anyone know how to trace functions inside a closure? I would like > to > > trace hanoi-move, however find that with MIT Scheme I need to place > (trace) > > > > within the closure (hanoi n), otherwise the trace will not occur. > > > > Can a trace like this be performed in Racket? > > > > Thanks > > > > (define (hanoi n) > > (define (pmd from to) > > (display "Move ") > > (display from) > > (display " to ") > > (display to) > > (newline) > > '()) > > (define (hanoi-move n from to spare) > > (cond ((= n 0) '()) > > ((= n 1) (pmd from to)) > > (else > > (hanoi-move (- n 1) from spare to) > > (hanoi-move 1 from to spare) > > (hanoi-move (- n 1) spare to from > > (hanoi-move n "A" "B" "C")) > > Yes, Racket has trace tools: > https://docs.racket-lang.org/reference/debugging.html > > Try adding (trace hanoi) before the call to (hanoi-move ) at the bottom > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAKD0t1%2Bn_W7%3Dc7%3D_KAcFuJQrFo86JBx8uGJuBfXY%2BgZrDFKHWg%40mail.gmail.com.
Re: [racket-users] trace facility in Racket?
On 3/21/20, dgtlcmo wrote: > Does anyone know how to trace functions inside a closure? I would like to > trace hanoi-move, however find that with MIT Scheme I need to place (trace) > > within the closure (hanoi n), otherwise the trace will not occur. > > Can a trace like this be performed in Racket? > > Thanks > > (define (hanoi n) > (define (pmd from to) > (display "Move ") > (display from) > (display " to ") > (display to) > (newline) > '()) > (define (hanoi-move n from to spare) > (cond ((= n 0) '()) > ((= n 1) (pmd from to)) > (else > (hanoi-move (- n 1) from spare to) > (hanoi-move 1 from to spare) > (hanoi-move (- n 1) spare to from > (hanoi-move n "A" "B" "C")) Yes, Racket has trace tools: https://docs.racket-lang.org/reference/debugging.html Try adding (trace hanoi) before the call to (hanoi-move ) at the bottom -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAFUu9R5RDgp%2BcdQ219FF14X9mp99qd%2BMB8T2tMRvfvKf8KKa2Q%40mail.gmail.com.
[racket-users] trace facility in Racket?
Does anyone know how to trace functions inside a closure? I would like to trace hanoi-move, however find that with MIT Scheme I need to place (trace) within the closure (hanoi n), otherwise the trace will not occur. Can a trace like this be performed in Racket? Thanks (define (hanoi n) (define (pmd from to) (display "Move ") (display from) (display " to ") (display to) (newline) '()) (define (hanoi-move n from to spare) (cond ((= n 0) '()) ((= n 1) (pmd from to)) (else (hanoi-move (- n 1) from spare to) (hanoi-move 1 from to spare) (hanoi-move (- n 1) spare to from (hanoi-move n "A" "B" "C")) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/92efb57d-6f32-47bb-89ec-98d9a4a5aed0%40googlegroups.com.