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 10:19:12 -0700

Neil Jerram wrote:

Hi Neil,

Back to this again:

>     >> (define client-input "")
>     >> (define (eval-client-input str)
>     >>   (stack-catch #t
>     >>     (lambda ()
>     >>       (call-with-input-string str
>     >>         (lambda (p)
>     >>           (set-port-filename! p (tpl-file))
>     >>           (set-port-line! p (string->number (tpl-file-line "%2$d")))
>     >>           (list (primitive-eval (read p))))))
>     >>     (lambda (key . args)
>     >>       ;; [1]
>     >>       (apply display-error (fluid-ref the-last-stack)
>     >>                            (current-error-port)
>     >>                            args)
>     >>       (set! stack-saved? #f)
>     >>       #f)))

> 1. No documentation :-)

Based on your example, I would need to emit this to libguile:

  (eval-client-input "...whatever...")

The problem is that the ``...whatever...'' is likely to often include
double quotes, backslashes and all kinds of interesting stuff.
I don't particularly want to go over the string and reformat it
so that the reader can reconstruct what I already have in hand.
What I want to do is along these lines:

>   {
>     SCM str = gh_str02scm( "...whatever..." );
>     scm_set_x( client_input_scm, str );
>     gh_eval_str( "(eval-client-input client-input)" );
>   }

of course, there _is_ no scm_set_x procedure and scm_m_set_x is indecipherable:

> /* Will go into the RnRS module when Guile is factorized.
> SCM_SYNTAX (s_set_x, "set!", scm_makmmacro, scm_m_set_x); */
> static const char s_set_x[] = "set!";
> SCM_GLOBAL_SYMBOL (scm_sym_set_x, s_set_x);
> 
> SCM
> scm_m_set_x (SCM xorig, SCM env SCM_UNUSED)
> {
>   SCM x = SCM_CDR (xorig);
>   SCM_ASSYNT (scm_ilength (x) == 2, scm_s_expression, s_set_x);
>   SCM_ASSYNT (SCM_SYMBOLP (SCM_CAR (x)), scm_s_variable, s_set_x);
>   return scm_cons (SCM_IM_SET_X, x);
> }

and it would be nice to figure out how to convert the string, "client-input"
into an SCM that is client-input.  :)




reply via email to

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