[plt-scheme] trace forms?

From: Yin-So Chen (yinso.chen at gmail.com)
Date: Fri Apr 27 00:03:17 EDT 2007

Hi Grant -

I think it's not too hard to implement it - I am still a macro newbie, but I
think below is what you want...

(module trace-helper mzscheme
  (require (lib "trace.ss"))
  (define-syntax trace-lambda
    (syntax-rules ()
      ((_ name (var ...) exp exp2 ...)
       (begin
         (letrec ((name (lambda (var ...) exp exp2 ...)))
           (trace name)
           name)))))
  (define-syntax trace-let
    (syntax-rules ()
      ((_ name ((var val) ...) exp exp2 ...)
       ((letrec ((name
                  (trace-lambda name (var ...)
                                exp exp2 ...)))
          name)
        val ...))))
  (provide (all-from (lib "trace.ss")))
  (provide (all-defined)))

(require trace-helper)

; example from chez
(define half
  (trace-lambda half (x)
    (cond
      [(zero? x) 0]
      [(odd? x) (half (- x 1))]
      [(even? x) (+ (half (- x 1)) 1)])))
(half 5)
(define half
  (trace-lambda half (x)
    (cond
      [(zero? x) 0]
      [(odd? x) (half (trace-let decr-value () (- x 1)))]
      [(even? x) (+ (half (- x 1)) 1)])))
(half 5)



On 4/26/07, Grant Rettke <grettke at acm.org> wrote:
>
> Yea don't get me wrong is a great tool.
>
> For some folks traced functions are nice for graphically illustrating
> "what happens", and help them better visualize things.
>
> On 4/26/07, jos koot <jos.koot at telefonica.net> wrote:
> >
> >
> > May be the Debug button of Drscheme can be useful for you. It allows
> > stepwise evaluation, breakpoints to be set and cleared and so on. This
> > functionality is available without corrupting your source code with
> tracing
> > command. All functions speek for themselves; you dont need a manual to
> use
> > it. In my opinion it's a fine tool.
> > Jos Koot
> >
> > (((((lambda(x)((((((((x x)x)x)x)x)x)x)x))
> >     (lambda(x)(lambda(y)(x(x y)))))
> >    (lambda(x)(x)x))
> >   (lambda()(printf "Greetings, Jos~n"))))
> >
> > ----- Original Message -----
> > From: Grant Rettke
> > To: plt-scheme at list.cs.brown.edu
> > Sent: Thursday, April 26, 2007 10:50 PM
> > Subject: [plt-scheme] trace forms?
> >
> > Hi,
> >
> > In Chez Scheme, there are trace forms for let and lambda (trace-let,
> > for example).
> >
> > It is pretty convenient. Is there something like this in MzScheme?
> >
> > How difficult is it to implement something like this?
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



-- 
http://www.yinsochen.com
...continuous learning...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070426/d932061d/attachment.html>

Posted on the users mailing list.