From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Linas Vepstas Newsgroups: gmane.lisp.guile.user Subject: Re: Guile bugs Date: Sun, 10 Sep 2017 14:56:20 -0500 Message-ID: References: <87lgtajpkc.fsf@web.de> <87h8y7ruuz.fsf_-_@gnu.org> <87y3pm7l6j.fsf@gnu.org> Reply-To: linasvepstas@gmail.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1505320956 13131 195.159.176.226 (13 Sep 2017 16:42:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Sep 2017 16:42:36 +0000 (UTC) Cc: Guile User To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Sep 10 21:57:32 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 1dr8Lp-0000yH-Lc for guile-user@m.gmane.org; Sun, 10 Sep 2017 21:57:05 +0200 Original-Received: from localhost ([::1]:54112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr8Lw-0002ho-Un for guile-user@m.gmane.org; Sun, 10 Sep 2017 15:57:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr8La-0002hd-9t for guile-user@gnu.org; Sun, 10 Sep 2017 15:56:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dr8LY-0006UR-L3 for guile-user@gnu.org; Sun, 10 Sep 2017 15:56:50 -0400 Original-Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:32946) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dr8LW-0006RQ-0u; Sun, 10 Sep 2017 15:56:46 -0400 Original-Received: by mail-lf0-x236.google.com with SMTP id c80so14211977lfh.0; Sun, 10 Sep 2017 12:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc; bh=8FAlRgHUB7xQeC4fxRZCRyfU0KWN66ORQAFhc2V3ttw=; b=feL6nc4QjPRhbSNBWlfYA9wHM4dRwUnTAU1ZDg2++DZhbdlkbozZyKx0uyZSD2CmOZ Bg51uHAepNkxi3eQCTYhHfNNcIzla5UpxSAk5TXbl+H2gclKEI1itg/gQFnc/RNd4n28 nUAMP7lFPDQvNNa0PXfO3ABK8+01TbXi81fnFouwp6kP/2P24rS91A7LoVJx+RsEO0rp VUoEPveWszypFKoE6nL88DZ3telOHHgPxEbLXSdWjFlWqN9O5PhRLuF8hWLlDxYis8Vz n73/9a50/U6A6xkgFe7Zng1BxxVKL2q1V6ioHcNbDIssorXg/lYJBl33F6kwI++JjZX7 +wEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=8FAlRgHUB7xQeC4fxRZCRyfU0KWN66ORQAFhc2V3ttw=; b=i9c0dc9RV50Fw/WWrhDk/Bl3MAc1U0Y5WYOPRL+lmo+I3MxTMOLCxY7/SlLRymmSfr tqugF0sxc7pnHPpX6yMsmTNqGMrqhD+wg+iKTUsDScYvaYe0xRKA+kB4IlTnBYiGg0kD yq8kclGqY/Aitv0GXPj4Lfc6on+MgwFTpzFpS9ljBrYB0W4ULyPrX9qO3UnIYQQzuVtq jTgoh6op/xM64KwRufWeL9KbHye+1Heij3pbfyXlwYD8A+LjWUjlpeitw5UVZCpvSBxo owiaZ4SyOCoOtZWLx9uu07wCM2KpHq6i4I0j7bHDU6o0Grk8lTvLERK/fhVMgX4hZ9L1 yOiQ== X-Gm-Message-State: AHPjjUhWatchQa70hSS1M8sy6Hnnl+waDF+cReWpwoMFPU51U1UkdXzY ueJUGxkpOqIq2gmv2kNSlsVWbm9rXZ15 X-Google-Smtp-Source: AOwi7QC/XC4dNzCu8uDUf1FKIyVhWre9iuex2p1GFy4ChiAERkoulBNf1u3Gf2WAEjO0XgoFjBSe39XXbcedtNhAW3I= X-Received: by 10.46.1.134 with SMTP id f6mr3426537lji.100.1505073401551; Sun, 10 Sep 2017 12:56:41 -0700 (PDT) Original-Received: by 10.25.44.200 with HTTP; Sun, 10 Sep 2017 12:56:20 -0700 (PDT) In-Reply-To: <87y3pm7l6j.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::236 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:14130 Hi Ludo, Perhaps I was too brief in my remarks. By a networked REPL, I meant this: https://www.gnu.org/software/guile/manual/html_node/REPL-Servers.html For accidental, historical reasons, (i.e. I did not know the above existed) I wrote my own variant, which accepts network connections, handles guile in full, including the printing of exception frames, handles async printing to stdio (i.e. to the network connection) so that long-running functions can print, and the user can see that output, unbuffered. Its full multi-threaded, uses a pool of threads pre-initialized in guile, hot and ready to go, to avoid the overhead of initializing and entering guile. Its fast, robust, it works. The stuff coming over the network sockets are bytes, not s-exps. Since none of the bytes are ever zero, they are effectively C/C++ strings, and are handled as such. These C strings are sent to scm_eval_string() wrapped by scm_c_catch(). As mentioned, this customized blob of code is easily 3x or 5x faster than (use-modules (system repl server)), and also more robust ... sometimes (system repl server) seems to lock up or hang or something, I have not delved into it. One of my complaints is that the C strings sent to scm_eval_string() go through some pointless layers that convert utf8 to utf32, and then back again. I do not recall the details. There are some obvious optimizations that can be performed. Its more than an afternoon or two but less than a week or two. I am not motivated to submit patches, as I fear these will just provoke arguments and be rejected. The custom guile network repl server can be viewed at the URL's below. To preserve your sanity, you probably don't want to study it. But in the spirit of open source, here it is: https://github.com/opencog/atomspace/blob/master/opencog/guile/SchemeEval.c= c The network REPL shell is here: https://github.com/opencog/opencog/blob/master/opencog/cogserver/shell/Gene= ricShell.cc we've layered both guile and python on it. Python is annoying because executing python from repl behaves differently than executing python from a file. Not my fault; its built into the python language definition. Idiots. --linas On Sun, Sep 10, 2017 at 8:11 AM, Ludovic Court=C3=A8s wrote: > Hi, > > Linas Vepstas skribis: > > > 1) There is a need to pass messages between subsystems running on > different > > machines. > > > > 2) Solutions include ROS, ZeroMQ, google protocol buffers... whatever. > All > > require lots of work, a learning curve, complexity, etc. > > > > 3) Wait! I know! I will just send around ascii (utf8) strings that are > > guile programs! Just use the guile repl server, connect to it, and sen= d > > some guile string! No muss, no fuss, no coding, no learning curve, > simple > > easy ... You can use netcat to drive things! echo (display "hello > > world\n") | nc 1.2.3.4 37146 > > Then you=E2=80=99re sending sexps, not strings, and you=E2=80=99re readin= g them with > =E2=80=98read=E2=80=99 from a port, as opposed to loading whole strings i= n memory. > > Also, the REPL server is not necessarily the right thing here. You > conceptually want a REPL, but not Guile=E2=80=99s full-blown REPL, which = can be > hard to deal with (you need to parse the prompts, determine if you=E2=80= =99re in > a recursive REPL, whether an exception occurred, etc.) > > In the Shepherd, I implemented a very simple REPL that is just enough to > communicate evaluation results to the client, and to distinguish return > values from exceptions. This does not use Guile=E2=80=99s REPL server, o= nly > =E2=80=98read=E2=80=99, =E2=80=98eval=E2=80=99, =E2=80=98write=E2=80=99. > > HTH, > Ludo=E2=80=99. > --=20 *"The problem is not that artificial intelligence will get too smart and take over the world," computer scientist Pedro Domingos writes, "the problem is that it's too stupid and already has." *