Re: Debugging REPL

Igor Hjelmstrom Vinhas Ribeiro <[email protected]> Sat, 16 May 2009 01:37:49 -0400
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
--===============2815731761869002757==
Content-Type: multipart/alternative; boundary=0016e6de152429ed75046a00f638

--0016e6de152429ed75046a00f638
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Daniel,

   This is very useful - thank you for this tip. Is the code in public
domain?

Regards,
 Igor.

On Tue, Jun 12, 2007 at 08:40, Daniel Sadilek <
[email protected]> wrote:

> Sorry, there was a bug in the last post. Correct form of debug must be:
>
> (define-syntax debug
>  (syntax-rules ()
>   ((_ var ...)
>    (begin
>      (print "Debugging. Available lexical bindings: " '(var) ...)
>       (let ((child-env (make-child-environment (interaction-environment))))
>        (putprop 'var child-env var) ...
>        (with-environment child-env (lambda ()
>                                     (repl)))
>        (print "Debugging ended."))))))
>
>
> On 6/12/07, Daniel Sadilek <[email protected]> wrote:
> > I found a workaround:
> >
> > (define-syntax debug
> >   (syntax-rules ()
> >     ((_ var ...)
> >      (begin
> >        (print "Debugging. Available lexical bindings: " '(var) ...)
> >        (putprop 'var (make-child-environment (interaction-environment))
> var) ...
> >        (repl)
> >        (print "Debugging ended.")))))
> >
> > This special syntactic form can be used like this:
> >
> > (define (f x)
> >   (let ((sq (* x x)))
> >     (debug x sq)
> >     (+ sq sq)))
> >
> > Does anyone know a better solution?
> >
> > Btw, I use the SchemeScript IDE and really like the editing style that
> > is made possible with the above debug-form. You can put "(debug
> > some-vars)" inside a procedure and execute it (or some other procedure
> > that calls it). Then, with access to the local variables, you can
> > write your code inside the procedure -- right in place -- and evaluate
> > by pressing Ctrl+Enter. If finished, you exit the debug REPL.
> > I'm interested, what is you preferred "editing cycle"?
> >
> > Best regards
> > Daniel Sadilek
> >
> > On 6/12/07, Daniel Sadilek <[email protected]> wrote:
> > > Hello all,
> > >
> > > for debugging, I want to start a REPL inside a procedure so that the
> > > lexical bindings inside the procedure are available.
> > >
> > > For example, if anything goes wrong in this procedure:
> > >
> > > (define (f x)
> > >   (let ((sq (* x x)))
> > >     (+ sq sq)))
> > >
> > > I would like to be able to change it to
> > >
> > > (define (f x)
> > >   (let ((sq (* x x)))
> > >     (debug-repl)
> > >     (+ sq sq)))
> > >
> > > and run it again. A REPL should be started in which I can access x and
> > > sq. Is this somehow possible?
> > > I couldn't figure out how I can make the lexical bindings accessible.
> > > Somehow the current environment would need to be accessed, wouldn't
> > > it?
> > >
> > > Best regards
> > > Daniel Sadilek
> > >
> >
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Sisc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sisc-users
>

--0016e6de152429ed75046a00f638
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Daniel,<br><br>=A0=A0 This is very useful - thank you for this tip. Is the =
code in public domain?<br><br>Regards,<br>=A0Igor.<br><br><div class=3D"gma=
il_quote">On Tue, Jun 12, 2007 at 08:40, Daniel Sadilek <span dir=3D"ltr">&=
lt;<a href=3D"mailto:[email protected]">[email protected]=
-berlin.de</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Sorry, there was =
a bug in the last post. Correct form of debug must be:<br>
<div class=3D"im"><br>
(define-syntax debug<br>
=A0(syntax-rules ()<br>
 =A0 ((_ var ...)<br>
 =A0 =A0(begin<br>
 =A0 =A0 =A0(print &quot;Debugging. Available lexical bindings: &quot; &#39=
;(var) ...)<br>
</div> =A0 =A0 =A0(let ((child-env (make-child-environment (interaction-env=
ironment))))<br>
 =A0 =A0 =A0 =A0(putprop &#39;var child-env var) ...<br>
 =A0 =A0 =A0 =A0(with-environment child-env (lambda ()<br>
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (r=
epl)))<br>
 =A0 =A0 =A0 =A0(print &quot;Debugging ended.&quot;))))))<br>
<div><div></div><div class=3D"h5"><br>
<br>
On 6/12/07, Daniel Sadilek &lt;<a href=3D"mailto:[email protected]=
in.de">[email protected]</a>&gt; wrote:<br>
&gt; I found a workaround:<br>
&gt;<br>
&gt; (define-syntax debug<br>
&gt; =A0 (syntax-rules ()<br>
&gt; =A0 =A0 ((_ var ...)<br>
&gt; =A0 =A0 =A0(begin<br>
&gt; =A0 =A0 =A0 =A0(print &quot;Debugging. Available lexical bindings: &qu=
ot; &#39;(var) ...)<br>
&gt; =A0 =A0 =A0 =A0(putprop &#39;var (make-child-environment (interaction-=
environment)) var) ...<br>
&gt; =A0 =A0 =A0 =A0(repl)<br>
&gt; =A0 =A0 =A0 =A0(print &quot;Debugging ended.&quot;)))))<br>
&gt;<br>
&gt; This special syntactic form can be used like this:<br>
&gt;<br>
&gt; (define (f x)<br>
&gt; =A0 (let ((sq (* x x)))<br>
&gt; =A0 =A0 (debug x sq)<br>
&gt; =A0 =A0 (+ sq sq)))<br>
&gt;<br>
&gt; Does anyone know a better solution?<br>
&gt;<br>
&gt; Btw, I use the SchemeScript IDE and really like the editing style that=
<br>
&gt; is made possible with the above debug-form. You can put &quot;(debug<b=
r>
&gt; some-vars)&quot; inside a procedure and execute it (or some other proc=
edure<br>
&gt; that calls it). Then, with access to the local variables, you can<br>
&gt; write your code inside the procedure -- right in place -- and evaluate=
<br>
&gt; by pressing Ctrl+Enter. If finished, you exit the debug REPL.<br>
&gt; I&#39;m interested, what is you preferred &quot;editing cycle&quot;?<b=
r>
&gt;<br>
&gt; Best regards<br>
&gt; Daniel Sadilek<br>
&gt;<br>
&gt; On 6/12/07, Daniel Sadilek &lt;<a href=3D"mailto:[email protected]=
-berlin.de">[email protected]</a>&gt; wrote:<br>
&gt; &gt; Hello all,<br>
&gt; &gt;<br>
&gt; &gt; for debugging, I want to start a REPL inside a procedure so that =
the<br>
&gt; &gt; lexical bindings inside the procedure are available.<br>
&gt; &gt;<br>
&gt; &gt; For example, if anything goes wrong in this procedure:<br>
&gt; &gt;<br>
&gt; &gt; (define (f x)<br>
&gt; &gt; =A0 (let ((sq (* x x)))<br>
&gt; &gt; =A0 =A0 (+ sq sq)))<br>
&gt; &gt;<br>
&gt; &gt; I would like to be able to change it to<br>
&gt; &gt;<br>
&gt; &gt; (define (f x)<br>
&gt; &gt; =A0 (let ((sq (* x x)))<br>
&gt; &gt; =A0 =A0 (debug-repl)<br>
&gt; &gt; =A0 =A0 (+ sq sq)))<br>
&gt; &gt;<br>
&gt; &gt; and run it again. A REPL should be started in which I can access =
x and<br>
&gt; &gt; sq. Is this somehow possible?<br>
&gt; &gt; I couldn&#39;t figure out how I can make the lexical bindings acc=
essible.<br>
&gt; &gt; Somehow the current environment would need to be accessed, wouldn=
&#39;t<br>
&gt; &gt; it?<br>
&gt; &gt;<br>
&gt; &gt; Best regards<br>
&gt; &gt; Daniel Sadilek<br>
&gt; &gt;<br>
&gt;<br>
<br>
-------------------------------------------------------------------------<b=
r>
This SF.net email is sponsored by DB2 Express<br>
Download DB2 Express C - the FREE version of DB2 express and take<br>
control of your XML. No limits. Just data. Click to get it now.<br>
<a href=3D"http://sourceforge.net/powerbar/db2/" target=3D"_blank">http://s=
ourceforge.net/powerbar/db2/</a><br>
_______________________________________________<br>
Sisc-users mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]=
forge.net</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/sisc-users" target=
=3D"_blank">https://lists.sourceforge.net/lists/listinfo/sisc-users</a><br>
</div></div></blockquote></div><br>

--0016e6de152429ed75046a00f638--


--===============2815731761869002757==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
--===============2815731761869002757==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Sisc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sisc-users

--===============2815731761869002757==--