From: Vladimir Zhbanov <vzhbanov@gmail.com>
To: guile-user@gnu.org
Subject: Re: REPL history
Date: Tue, 7 Mar 2017 00:44:29 +0300 [thread overview]
Message-ID: <20170306214429.GB27659@localhost.localdomain> (raw)
In-Reply-To: <87d1du9ln0.fsf@pobox.com>
On Mon, Mar 06, 2017 at 09:48:51PM +0100, Andy Wingo wrote:
> On Mon 06 Mar 2017 20:15, Vladimir Zhbanov <vzhbanov@gmail.com> writes:
>
> > OK, put things other ways. I have a GUI app which starts REPL in
> > another thread. Is there a way to call a thunk in that REPL from
> > the GUI app? Basically, I want it to exit gracefully by calling
> > (quit) in the REPL before GUI exits.
>
> What if, in your GUI app, you call stop-server-and-clients! from (system
> repl server) ? That aborts to a prompt to unwind the stack, so it's not
> catchable but a dynamic-wind out guard will run. Only really works in
> 2.2 tho I think.
Well, I confused things, as I already said, and my first question
was incorrect. Really, I have a procedure something like the following:
(define (my-repl)
(let ((repl (make-repl (current-language) #f))
(history-filename (make-custom-history-filename)))
(repl-eval repl
`(begin
(use-modules (ice-9 session) ; help, apropos and such
(system repl command)) ; guile meta-commands
(display "Welcome to my REPL!\n" (current-error-port))
(resolve-module '(ice-9 readline))
;; After resolving that module the variable
;; *features* should contain 'readline.
(if (provided? 'readline)
(begin
(use-modules (ice-9 readline))
((@ (ice-9 readline) activate-readline))
((@ (ice-9 readline) read-history) ,history-filename))
(display "Readline is not supported in your configuration.\n")
(current-error-port))))
(run-repl repl)))
So I don't use repl server here.
What I tried so far is to manually save dynamic state in repl:
(define ds (current-dynamic-state))
and use it in GUI (with support of guile expression evaluation):
(with-dynamic-state ds (lambda () (write-history history-filename)))
This is for readline history saving, and works pretty well.
So I was thinking to bake something like this into the above code,
probably by adding a variable on the repl-eval stage to store
initial dynamic state in repl. The problem occured when I started
to call (quit) or (throw 'quit) the same way, that is, in the
thunk called in with-dynamic-state. It just segfaulted.
And my app is tied to 2.0 these days.
--
Vladimir
next prev parent reply other threads:[~2017-03-06 21:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-05 17:06 REPL history Vladimir Zhbanov
2017-03-05 17:57 ` tomas
2017-03-06 19:15 ` Vladimir Zhbanov
2017-03-06 20:29 ` tomas
2017-03-06 20:48 ` Andy Wingo
2017-03-06 21:44 ` Vladimir Zhbanov [this message]
2017-03-07 9:23 ` Andy Wingo
2017-03-07 14:44 ` Vladimir Zhbanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170306214429.GB27659@localhost.localdomain \
--to=vzhbanov@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).