guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PLEASE: debugging embedded guile code


From: Bruce Korb
Subject: Re: PLEASE: debugging embedded guile code
Date: Fri, 16 May 2003 19:33:45 -0700

Bruce Korb wrote:

> The issue here is that gh_eval_str processes the *entire* string and
> returns the result of the last expression.  This "eval-client-input"
> function does not behave in the same way:

> ... How do I make
> that ``(list (primitive-eval (read p)))'' thing into a loop that
> yields the last value?

Answer:  (begin ... )
EXCEPT:  the problem now is that instead of getting the final result,
         the returned SCM is an SCM *PAIR*, not the value I need.

That was because the result of the primitive-eval should not
be listified:
>          (list (primitive-eval (read p))) ) ) )

OK.  Here's what I have now:

> (use-modules (ice-9 stack-catch))
> (use-modules (ice-9 debug))
> 
> (read-enable 'positions)
> 
> (define (eval-client-input str)
>   (stack-catch #t
> 
>     (lambda ()
>       (call-with-input-string
>         (string-append "(begin " str ")")   ;;;  <<--== ICK!!
>         (lambda (p)
>           (set-port-filename! p (tpl-file))
>           (set-port-line! p (string->number (tpl-file-line "%2$d")))
>           (primitive-eval (read p)) ) ) )
> 
>     (lambda (key . args)
>       (apply display-error
>          (fluid-ref the-last-stack)
>          (current-error-port)
>          args)
>       (set! stack-saved? #f)
>       (error "exiting") )
> ) )

It's really close, but for two problems:

1.  "primitive-eval" doesn't seem to like comments:

> ERROR: In procedure list:
> ERROR: end of file in ./auto_gen.tpl
> Error in template ./auto_gen.tpl, line 675
>         DEFINITIONS ERROR in ./auto_gen.tpl line 675 for autogen.texi:
>         exiting
> Failing Guile command:  = = = = =
> 
> (shell "[ -f autogen.texi.ori ] && rm -f autogen.texi.ori
>        rm -rf ${tempdir}")
> (set-writable #t)
> 
> ;; Local Variables:
> ;; indent-tabs-mode: nil
> ;; mode: texinfo
> ;; End:
> 
> =================================

2. if you notice, the lines beginning with "ERROR:" still don't
   have the line number, but I see the file name there!!
   (Please note:  by this point, I've run through many templates.
   Likely this is the only one with scheme comments at the end.)

3. It seems (current-error-port) is set to something that got
   squirreled away when gh_enter got called.  I've scoured the
   manual now.  How do I simply set error port to the current stderr?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]