This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Here's a guile profiling tool/a question/a *remarkable* guile fact (was Re: Guile profiling tools?)


hjstein@bfr.co.il (Harvey J. Stein) writes:

> In particular, the following is illegal, but both guile & STk allow
> it:
>    guile> (define (f x y)
> 	     (define r1 (* x y))
> 	     (define r2 (* 2 r1))
> 	     (list r1 r2))

When you take this a few steps further, you can actually cause Guile
(and SCM I think) to loose:

    (define (f x y)
      (define r1 (* x y))
      (define (bar)
	r1)
      (define r2 (* 2 (bar)))
      (bar))

    (foo 1 2)
    => #<procedure bar ()>   ;; OOPS - should be 2

So don't fo this.  Ideally, Guile should produce a error for this, at
least the debugging evaluator.