From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Remco Bras Newsgroups: gmane.lisp.guile.user Subject: Re: Can scm_shell be interrupted? Date: Fri, 16 May 2008 18:29:02 +0200 Message-ID: <200805161829.02777.vrsoft@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1210971453 17641 80.91.229.12 (16 May 2008 20:57:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 May 2008 20:57:33 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri May 16 22:58:09 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jx6zn-00073V-PT for guile-user@m.gmane.org; Fri, 16 May 2008 22:57:44 +0200 Original-Received: from localhost ([127.0.0.1]:52987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jx6z4-0004iy-BG for guile-user@m.gmane.org; Fri, 16 May 2008 16:56:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jx2ny-0004Xd-Sf for guile-user@gnu.org; Fri, 16 May 2008 12:29:14 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jx2nw-0004WM-AR for guile-user@gnu.org; Fri, 16 May 2008 12:29:14 -0400 Original-Received: from [199.232.76.173] (port=37748 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jx2nw-0004WH-6c for guile-user@gnu.org; Fri, 16 May 2008 12:29:12 -0400 Original-Received: from nf-out-0910.google.com ([64.233.182.191]:6604) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jx2nv-0003Xt-En for guile-user@gnu.org; Fri, 16 May 2008 12:29:11 -0400 Original-Received: by nf-out-0910.google.com with SMTP id c7so386555nfi.26 for ; Fri, 16 May 2008 09:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date:user-agent:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; bh=dZ+ErpUIUOWdEipn2CjjESl7XTgZlnKYLmT+vAh+4qw=; b=CgMtlSyJHbb0EiTOQTecox7d3s1RpneFXVxTE1lfbIHyw2UvktC6eLhS4lbe9gA715XY7ERynyrjJrNfkkZSWymjLLTvyF8SAfkYnU+8uhVPLFr6dTfoysWeTWVCZw5yPoDqRLq+qw4qby9sGiRAQ8Y+x0j8+VbCIMtZ3O9+rBg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=YDyYOfc3BO2vO+lr3KnRMLB4N7pXkDatWNfDPOf4dhPSp0w5vEMGLA4nwmELqUter8xplS+KojWuTFAVjBHWBXZdfB7mEro27WgGZqgCA8hKqSrccEoQqOrme/tFLHonHU65IRVEGssYGdEt17hjb15m6IR2P3UCT8fOCVxkipw= Original-Received: by 10.210.28.4 with SMTP id b4mr3882844ebb.40.1210955347158; Fri, 16 May 2008 09:29:07 -0700 (PDT) Original-Received: from zero-desktop.local ( [86.91.128.48]) by mx.google.com with ESMTPS id d24sm22010731nfh.2.2008.05.16.09.29.04 (version=SSLv3 cipher=RC4-MD5); Fri, 16 May 2008 09:29:04 -0700 (PDT) User-Agent: KMail/1.9.9 Content-Disposition: inline X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-Mailman-Approved-At: Fri, 16 May 2008 16:56:05 -0400 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:6567 Archived-At: Hello, after the last exchange in this thread, I wrote and tested a prototype of a repl for my app. The code for this is as follows: int exec_guile_shell (void *unused_arg) { scm_init_guile(); /*Horribly inefficient*/ while(1) { SCM_TICK; SDL_mutexP(repl_signal); scm_simple_format(scm_current_output_port(),scm_from_locale_string(PROMPT),SCM_EOL); scm_simple_format(scm_current_output_port(),scm_from_locale_string("~S"),scm_list_1 (scm_primitive_eval(scm_read(scm_current_input_port())))); scm_newline(scm_current_output_port()); SDL_mutexV(repl_signal); } return 0; //never reached, just here to please gcc. } This is run when the app starts, after using scm_c_define_gsubr to define the primitive interface my app exports and after scm_c_primitive_load is used to read in user-defined scheme files. When this function runs, the repl_signal mutex is already locked, after which a user's file may use (run-repl) to tell the main loop to unlock the mutex. For the most part, this works fine, but if I use this REPL to evaluate a call to one of the functions I have defined using scm_c_define_gsubr, for example (stop-repl), the function is unbound in the environment the REPL uses. I've tried using scm_interaction_environment() as a second argument to scm_eval rather than using scm_primitive_eval, but that did not solve this problem. I'm using guile 1.8.4 on GNU/Linux, in case that's relevant. Also, when evaluating files using scm_c_primitive_load, the previously defined functions are bound, regardless of whether they were defined by scm_c_define_gsubr or another file. Regards, Remco.