From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: rm@fabula.de Newsgroups: gmane.lisp.guile.devel Subject: Re: Bug in eval-string? Date: Fri, 9 Aug 2002 11:35:31 +0200 Sender: guile-devel-admin@gnu.org Message-ID: <20020809093531.GA25104@www> References: <20020808125641.GA23831@www> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1028885000 32170 127.0.0.1 (9 Aug 2002 09:23:20 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 9 Aug 2002 09:23:20 +0000 (UTC) Cc: rm@fabula.de, guile-devel@gnu.org Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17d5zJ-0008Md-00 for ; Fri, 09 Aug 2002 11:23:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17d605-0000Or-00; Fri, 09 Aug 2002 05:24:05 -0400 Original-Received: from www.elogos.de ([212.18.192.92]) by fencepost.gnu.org with smtp (Exim 3.35 #1 (Debian)) id 17d5za-0000Lq-00 for ; Fri, 09 Aug 2002 05:23:35 -0400 Original-Received: by www.elogos.de (Postfix, from userid 5001) id 56C0A1049A6; Fri, 9 Aug 2002 11:35:31 +0200 (CEST) Original-To: Neil Jerram Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.24i Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1042 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1042 First of all, thank's for all these replies. I think my problem stems partly from a missunderstanding of the documentation and from a missunderstanding of the implementation (which admittedly i could have examined myself. Sorry). On Thu, Aug 08, 2002 at 10:27:59PM +0100, Neil Jerram wrote: > [...] > rm> (let ((interaction-environment (lambda () boxx))) > rm> (format #t "Meaning of life in a box is: ~A\n" > rm> (eval-string "meaning-of-life"))) > > This isn't Elisp! The interaction-environment variable introduced by > your let has nothing to do with the builtin interaction-environment, > to which the documentation refers. I think i (wrongly) assumend that eval-string is "syntactic sugar" for eval. So my reading of the documentation made me belive that eval-string would behave like the following (pseudo)code: (use-modules (ice-9 syncase)) (define-syntax my-eval-string (syntax-rules () ((my-eval-string string) (eval (with-input-from-string string (lambda () (read))) (interaction-environment))))) maybe the documentation should be modified: "Evaluation takes place in the environment returned by the\n" "procedure @code{interaction-environment}.") to "Evaluation takes place in the same environment as \n" "returned by the procedure @code{interaction-environment}.") > BTW, note that the builtin interaction-environment is (at least at the > moment) identical to current-module. Ah, that information would have helped. > guile> (define boxx (make-module)) > guile> (set-module-kind! boxx 'directory) > directory > guile> (module-define! boxx 'meaning-of-life 42) > #f > guile> (save-module-excursion > (lambda () > (set-current-module boxx) > (eval-string "meaning-of-life"))) > 42 > guile> Where would i find documentation on save-module-excursion? And now for the RFC part: Wouldn't the 'eval*' interface be clearer and more orthogonal if eval-string would have a second, optional parameter specifying the environment/module in which evaluation should take place. If no module is specified the environment defaults to interaction-environment (this guarantees backward compatibility). The modifications to the code are minimal, see below. Ralf -- File: strports.c --------x-------------------------------------------- SCM_DEFINE (scm_eval_string, "eval-string", 1, 1, 0, (SCM string, SCM environ), "Evaluate @var{string} as the text representation of a Scheme\n" "form or forms, and return whatever value they produce.\n" "Evaluation takes place in the environment provided in the \n" "second, optional parameter @var{environ}. If none is given \n" "evalution will happen in the environment returned by the \n" "procedure @code{interaction-environment}.") #define FUNC_NAME s_scm_eval_string { SCM port = scm_mkstrport (SCM_INUM0, string, SCM_OPN | SCM_RDNG, "eval-string"); if (SCM_UNBNDP (environ)) environ = scm_interaction_environment (); return scm_c_call_with_current_module (environ, inner_eval_string, (void *)port); } #undef FUNC_NAME _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel