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: set-current-module in .guile ? Date: Wed, 09 Apr 2008 21:16:43 +0100 Message-ID: <873apupyvo.fsf@ossau.uklinux.net> References: <18423.46537.161648.253613@entangle.lvc.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1207772239 32613 80.91.229.12 (9 Apr 2008 20:17:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Apr 2008 20:17:19 +0000 (UTC) Cc: guile-user@gnu.org To: walck@lvc.edu Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Apr 09 22:17:52 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 1Jjgju-00036l-7u for guile-user@m.gmane.org; Wed, 09 Apr 2008 22:17:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JjgjG-0002jg-H6 for guile-user@m.gmane.org; Wed, 09 Apr 2008 16:17:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jjgit-0002dg-40 for guile-user@gnu.org; Wed, 09 Apr 2008 16:16:47 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jjgis-0002dN-Fd for guile-user@gnu.org; Wed, 09 Apr 2008 16:16:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jjgis-0002dI-A9 for guile-user@gnu.org; Wed, 09 Apr 2008 16:16:46 -0400 Original-Received: from mail3.uklinux.net ([80.84.72.33]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jjgir-00009E-NB for guile-user@gnu.org; Wed, 09 Apr 2008 16:16:45 -0400 Original-Received: from arudy (host86-145-183-175.range86-145.btcentralplus.com [86.145.183.175]) by mail3.uklinux.net (Postfix) with ESMTP id 632261F68CE; Wed, 9 Apr 2008 21:16:44 +0100 (BST) Original-Received: from laruns (laruns [192.168.0.10]) by arudy (Postfix) with ESMTP id 721133800D; Wed, 9 Apr 2008 21:16:43 +0100 (BST) In-Reply-To: <18423.46537.161648.253613@entangle.lvc.edu> (Scott N. Walck's message of "Sat, 5 Apr 2008 13:24:25 -0400") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 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:6531 Archived-At: "Scott N. Walck" writes: > Dear Guilers, > > Dan Gildea has ported a large fraction of Gerry Sussman's scmutils > code from MIT-scheme to guile. That sounds interesting! > In doing so, he uses guile modules > instead of MIT-scheme environments. Much of the code creates a module > called "generic-environment". In an interactive guile session, you > type > > (set-current-module generic-environment) > > and this redefines "+", for example, to add functions and vectors. > > I would like to know if there is a way to set the interactive > environment to "generic-environment" in a .guile file. If I put > > (set-current-module generic-environment) > > in a .guile file, it does nothing. (I suppose because the current > module when reading the .guile file is different from the current > module in an interactive guile session?) Some further thoughts on this... When you invoke Guile interactively, what it actually does is run a canned script, namely: (begin (turn-on-debugging) (load-user-init) ; This loads your .guile (top-repl)) All of those procedures are defined in ice-9/boot-9.scm, so you can see what they do by looking at their code. The cause of your specific problem is that (top-repl) does: (let ((guile-user-module (resolve-module '(guile-user)))) ... (set-current-module guile-user-module) ... So even though (set-current-module generic-environment) in .guile does have an effect, that effect is overridden by the later set-current-module call here. One overall solution is to settle for (guile-user) being your current module, and import everything you need from generic-environment by making (guile-user) use generic-environment - as has been suggested (and hopefully now debugged!) by others. Another option is to take a copy of the (top-repl) code, and modify it to do what you want - i.e. the set the current module to generic-environment, instead of to (guile-user). Then you can create a file containing the definition of scmutils-top-repl, and top level code: (begin (turn-on-debugging) (load-user-init) (scmutils-top-repl)) and invoke as "guile -s ". Hope that helps; let us know if you have further questions! Regards, Neil