Re: Suggested change to STk

From: Erick Gallesio <eg_at_kaolin.unice.fr>
Date: Sat, 06 Sep 1997 19:45:02 +0200

Shiro Kawai writes:
> If you cannot link stk into your program for some reason, how about
> writing small scheme code including your own repl, which doesn't
> echo toplevel results? (It's actually not read-eval-print-loop, but
> read-eval-loop)
>
> I tested following quick hack just now and seems to work. But maybe
> in your project you have some other reason which prevents you from
> doing it...
>
> % cat t.stk
> (define (repl)
> (eval (read))
> (flush)
> (repl))
> (repl)
>
> % stk -l t.stk
> Welcome to the STk interpreter version 3.1 [IRIX-5.X-IPxx]
> Copyright (I)(B 1993-1996 Erick Gallesio - I3S - CNRS / ESSI <eg_at_unice.fr
> >
> 'a
> 'b
> (display "abc\n")
> abc
> (quit)
> %

Yes you can even put your repl loop in a dynamic-wind to be sure to not break
it in case of error. Something like:

    (define (repl)
      (letrec ((continue #t)
                (repl-loop (lambda ()
                             (let ((x (read)))
                               (if (eof-object? x)
                                   (set! continue #f)
                                   (begin (eval x) (repl-loop)))))))
        (dynamic-wind (lambda () #f)
                      repl-loop
                      (lambda () (if continue (repl))))))

should do the trick.

However rather Raymond patch given by Kumar will not be necessary
since for next release, the interactive prompt and evaluation result
will be displayed by the Scheme functions repl-display-prompt and
repl-display-result. Of course theses functions can be redefined if needed.
For instance current default value for repl-display-result procedure is

    (define (repl-display-result result)
       (unless (eqv? result (make-undefined))
          (write result)
          (newline)))

Note: this procedure prints nothing if the result is #[undefined], since
the printing of this value is disappointing for some users (especially
after a define ...).


                -- Erick
Received on Sat Sep 06 1997 - 21:07:32 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST