[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
translators and scoping rules (was: Re: language translator help)
From: |
John W. Eaton |
Subject: |
translators and scoping rules (was: Re: language translator help) |
Date: |
Sat, 27 Apr 2002 19:54:27 -0500 |
On 27-Apr-2002, Neil Jerram <address@hidden> wrote:
| What are the Octave scoping rules? For dynamic scoping (a la Elisp),
| Guile has the address@hidden' macro for setting and restoring such variables'
| values. In the Elisp case, this allows Elisp variables to be Guile
| variables directly. (Except that it doesn't cope with buffer-local,
| etc.)
The scoping rules are fairly simple. Variables are local to functions
unless declared global. Global variables all share the same common
global namespace.
The eval() function can introduce new local variables. How would you
do that with Guile?
Something like this
(define foo
(lambda ()
(let ((x 21))
(eval-string "(define a (* 2 21))")
(display a)
(newline))))
works to define a new variable "a", but once foo has been evaluated,
the variable "a" is visible outside the scope of the function:
guile> a
ERROR: In expression a:
ERROR: Unbound variable: a
ABORT: (unbound-variable)
Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
guile>
guile>
guile> (define foo
... (lambda ()
... (let ((x 21))
... (eval-string "(define a (* 2 21))")
... (display a)
... (newline))))
guile>
guile> (foo)
42
guile> a
42
How would you use eval to introduce a new local variable?
jwe
- Re: loop translations (was: Re: language translator help), (continued)
- Re: loop translations (was: Re: language translator help), Marius Vollmer, 2002/04/28
- Re: loop translations (was: Re: language translator help), John W. Eaton, 2002/04/28
- Re: loop translations (was: Re: language translator help), Marius Vollmer, 2002/04/28
- Re: loop translations (was: Re: language translator help), Marius Vollmer, 2002/04/28
- Re: loop translations (was: Re: language translator help), Clinton Ebadi, 2002/04/29
- Re: loop translations (was: Re: language translator help), Eric E Moore, 2002/04/29
- Re: loop translations (was: Re: language translator help), Eric E Moore, 2002/04/30
- Re: loop translations (was: Re: language translator help), Neil Jerram, 2002/04/28
translators and scoping rules (was: Re: language translator help),
John W. Eaton <=
Re: translators and scoping rules (was: Re: language translator help), Per Bothner, 2002/04/28
Re: translators and scoping rules (was: Re: language translator help), John W. Eaton, 2002/04/28
Re: translators and scoping rules (was: Re: language translator help), Per Bothner, 2002/04/29
Re: translators and scoping rules (was: Re: language translator help), John W. Eaton, 2002/04/29
Re: translators and scoping rules (was: Re: language translator help), Neil Jerram, 2002/04/28