From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Vladimir Zhbanov Newsgroups: gmane.lisp.guile.user Subject: Re: REPL history Date: Tue, 7 Mar 2017 00:44:29 +0300 Message-ID: <20170306214429.GB27659@localhost.localdomain> References: <20170305170631.GA4916@localhost.localdomain> <20170305175713.GA19769@tuxteam.de> <20170306191502.GA27659@localhost.localdomain> <87d1du9ln0.fsf@pobox.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: blaine.gmane.org 1488836700 27376 195.159.176.226 (6 Mar 2017 21:45:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Mar 2017 21:45:00 +0000 (UTC) User-Agent: Mutt/1.5.23 (2014-03-12) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Mar 06 22:44:55 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cl0R2-0006IK-Lo for guile-user@m.gmane.org; Mon, 06 Mar 2017 22:44:52 +0100 Original-Received: from localhost ([::1]:46295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cl0R8-00045p-JC for guile-user@m.gmane.org; Mon, 06 Mar 2017 16:44:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cl0Qo-00045k-4R for guile-user@gnu.org; Mon, 06 Mar 2017 16:44:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cl0Qj-0001aY-6e for guile-user@gnu.org; Mon, 06 Mar 2017 16:44:38 -0500 Original-Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:35753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cl0Qi-0001aP-Vt for guile-user@gnu.org; Mon, 06 Mar 2017 16:44:33 -0500 Original-Received: by mail-lf0-x22b.google.com with SMTP id j90so41921206lfk.2 for ; Mon, 06 Mar 2017 13:44:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=08D5Y0KCGF5u0Qrtc2HsPtpawXJHGeppqhbR5EXX0Eo=; b=iCPIgk/ViA02FHCc88CfprJY5Tr9BDp9EIx9rx14xfU+w7cUhZuLff+DYzDi+YTgNF rouvn+GAM0+z1u3SL8vs41XikYDALXhoAAeg7l9NiwGhfzWCtOmlJsm231tNMYW1k5nk HcYrRBg3dWoyHPt4Ajyk3cqE06sCOpn3MqVsVxw/WhoqUFIYkoo/XeNEyg7XnHXoFX1a 8RgcMNfxkIZtuMprH7Y0msVeH6MCX4jxshJK1sYKeiW5k7fbt8DisBGRQlKkigrHKSoq fWhl+LibGq5VlsBoGHX+y7hCoswc9nRGOMUDiwIOT5cU69GBdRfu+ogPNoRMRoYCdfLf rREA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=08D5Y0KCGF5u0Qrtc2HsPtpawXJHGeppqhbR5EXX0Eo=; b=pzMhczRZHj7e7USIhLLNoxLALSVSGilEEZ0+IFoNTv6y7fJq8NuO4o5eEtnbeQvx/l jltzBy2qYj0/LqFPZMly88HCajUaaiZJLpZUQJ/dbR7nyzByzku3ckrL+Rf6OIAWGXRX cB9UpHBi8E4gIrYwvt6UFdRsJt5gh2wk8DCNm9YuUqSCLrMmz2GXZlzPD/+QyQ4ptemy b1Ij1oHSRkABqyoy7GAD2wcsai1BT6b40gvzMw2PHHuH84cmzPQ7vSGrBSsBkBgcM7zU XYzN5I5mqIquwhIb0eE2fSyivnzS/e3qIBE5roUi3h7rcRJpUaDxT2aW60iJghcIGYxp 7cjA== X-Gm-Message-State: AMke39k7XFxYs03asl+UBoFIVMZrUODR6FZ12d6bVReyHhuGzg8PHJmGI9puoP5m/JXhfQ== X-Received: by 10.25.72.145 with SMTP id v139mr5548458lfa.74.1488836671190; Mon, 06 Mar 2017 13:44:31 -0800 (PST) Original-Received: from newvzh.vzh ([213.24.125.114]) by smtp.gmail.com with ESMTPSA id x26sm4355450lja.10.2017.03.06.13.44.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 13:44:30 -0800 (PST) Original-Received: from vovka by newvzh.vzh with local (Exim 4.84_2) (envelope-from ) id 1cl0Qf-00089V-JH for guile-user@gnu.org; Tue, 07 Mar 2017 00:44:29 +0300 Mail-Followup-To: guile-user@gnu.org Content-Disposition: inline In-Reply-To: <87d1du9ln0.fsf@pobox.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22b X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13432 Archived-At: On Mon, Mar 06, 2017 at 09:48:51PM +0100, Andy Wingo wrote: > On Mon 06 Mar 2017 20:15, Vladimir Zhbanov 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