From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Guile Interpreter as a Standalone Server Date: Fri, 20 Oct 2006 21:45:26 +0100 Message-ID: <87fydizpg9.fsf@ossau.uklinux.net> References: <20061005180035.GA1376@alamut> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1161383146 14245 80.91.229.2 (20 Oct 2006 22:25:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 20 Oct 2006 22:25:46 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Oct 21 00:25:42 2006 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Gb2o6-0005zT-1H for guile-user@m.gmane.org; Sat, 21 Oct 2006 00:25:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gb2o5-0007hT-AF for guile-user@m.gmane.org; Fri, 20 Oct 2006 18:25:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gb1G4-0005kE-8u for guile-user@gnu.org; Fri, 20 Oct 2006 16:46:24 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gb1G2-0005jl-7h for guile-user@gnu.org; Fri, 20 Oct 2006 16:46:23 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gb1G1-0005jc-SJ for guile-user@gnu.org; Fri, 20 Oct 2006 16:46:22 -0400 Original-Received: from [80.84.72.33] (helo=mail3.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gb1G1-0004ko-AM for guile-user@gnu.org; Fri, 20 Oct 2006 16:46:21 -0400 Original-Received: from laruns (host217-43-46-97.range217-43.btcentralplus.com [217.43.46.97]) by mail3.uklinux.net (Postfix) with ESMTP id BBE1940A60E; Fri, 20 Oct 2006 20:46:15 +0000 (UTC) Original-Received: from laruns (laruns [127.0.0.1]) by laruns (Postfix) with ESMTP id EFBB86F58C; Fri, 20 Oct 2006 21:45:26 +0100 (BST) Original-To: Volkan YAZICI In-Reply-To: <20061005180035.GA1376@alamut> (Volkan YAZICI's message of "Thu, 5 Oct 2006 21:00:35 +0300") User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:5615 Archived-At: Volkan YAZICI writes: > Hi, > > I need such a feature: > > /* > * If there's an already running guile process in the background, > * return it, otherwise create a new one and return new process. > */ > interp = guile_interp(...); I appreciate that Ludovic has already replied to you about this, but I thought I'd some more thoughts. I think the core of this idea is pretty simple to implement, and I've appended a basic (and untested!) implementation of the server below. After the basics, however, I think you would quickly run into practical problems that are more tricky, such as whether you really want an eval from one client to affect global data for another one; what to do about error handling; what to do if an evaluation hangs; whether you want to constrain evaluations so that they take place in a "safe" environment; and so on. In my view, addressing all of these things carefully would make for an interesting project. > With such a functionality, it'd be possible to > > - Parse & execute faster. (We won't need to create a new process > everytime.) Is this for a specific application, out of interest? > - Cache parse plans. I don't understand what this item means. > - Use global variables that's accessible by any process using the > same interpreter. Yes - assuming that that is a desirable feature, in general. > Is such a feature already supported by Guile? Can I achieve above 3 > functionalities with using another method? This doesn't feel to me like something that needs to be supported by core Guile; it feels like a useful application that can be built on top of Guile. Regards, Neil (let loop ((server (let ((s (socket PF_INET SOCK_STREAM 0))) (setsockopt s SOL_SOCKET SO_REUSEADDR 1) (bind s AF_INET INADDR_ANY port) (listen s 5) s)) (clients '()) (readable '())) (if (null? readable) ;; Do a new select. (loop server clients (car (select (cons server clients) '() '()))) ;; Handle next readable socket. (let ((s (car readable))) (if (eq? s server) ;; Accept new connection. (loop server (cons (car (accept s)) clients) (cdr readable)) ;; Read from existing connection. (let ((x (read s))) (if (eof-object? x) ;; Connection closed. (loop server (delq s clients) (cdr readable)) ;; New form to evaluate. (begin (write (eval x (current-module)) s) (loop server clients (cdr readable))))))))) _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://lists.gnu.org/mailman/listinfo/guile-user