[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in eval-string?
From: |
rm |
Subject: |
Re: Bug in eval-string? |
Date: |
Fri, 9 Aug 2002 11:35:31 +0200 |
User-agent: |
Mutt/1.3.24i |
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
- Re: Bug in eval-string?, (continued)
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/10
- Re: Bug in eval-string?, Matthias Koeppe, 2002/08/12
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/12
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/14
- Re: Bug in eval-string?, Neil Jerram, 2002/08/19
- Re: Bug in eval-string?, Matthias Koeppe, 2002/08/20
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/21
- Emacs variables (was: Bug in eval-string?), Matthias Koeppe, 2002/08/27
- Re: Emacs variables (was: Bug in eval-string?), Marius Vollmer, 2002/08/31
Re: Bug in eval-string?, Neil Jerram, 2002/08/08
- Re: Bug in eval-string?,
rm <=