* Can't get outside bindings in the string expression with eval-string @ 2011-10-18 14:32 Nala Ginrut 2011-10-18 14:42 ` Nala Ginrut 2011-10-18 14:59 ` Andy Wingo 0 siblings, 2 replies; 4+ messages in thread From: Nala Ginrut @ 2011-10-18 14:32 UTC (permalink / raw) To: guile-devel [-- Attachment #1: Type: text/plain, Size: 882 bytes --] hi guys, I want to get a variable bidden from outside environment, such as the code below: -----------------------correct code------------------------ (define fp (open-output-file "/tmp/aaa")) (eval-string "(write 123 fp)" (current-module)) -------------------------end---------------------------------- This code can run successfully. But I want to use this trick in a procedure: -----------------------wrong code------------------------------ (define (func) (let ((fp (open-output-file "/tmp/aaa"))) (eval-string "(write 123 fp)" (current-module)) )) -----------------------end code------------------------------------ Guile will throw : ======================================== scheme@(guile-user)> (func) ERROR: In procedure memoize-variable-access!: ERROR: Unbound variable: fp0 ======================================== Is this a bug? Or I missed something? [-- Attachment #2: Type: text/html, Size: 1233 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't get outside bindings in the string expression with eval-string 2011-10-18 14:32 Can't get outside bindings in the string expression with eval-string Nala Ginrut @ 2011-10-18 14:42 ` Nala Ginrut 2011-10-18 14:59 ` Andy Wingo 1 sibling, 0 replies; 4+ messages in thread From: Nala Ginrut @ 2011-10-18 14:42 UTC (permalink / raw) To: guile-devel [-- Attachment #1: Type: text/plain, Size: 37 bytes --] sorry for the typo: s/bidden/bound/g [-- Attachment #2: Type: text/html, Size: 47 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can't get outside bindings in the string expression with eval-string 2011-10-18 14:32 Can't get outside bindings in the string expression with eval-string Nala Ginrut 2011-10-18 14:42 ` Nala Ginrut @ 2011-10-18 14:59 ` Andy Wingo [not found] ` <CAPjoZoeUQ7aokEUzeQ1f+Ge1zPOkEQcLgwdTiC5YJtDRR2hrqg@mail.gmail.com> 1 sibling, 1 reply; 4+ messages in thread From: Andy Wingo @ 2011-10-18 14:59 UTC (permalink / raw) To: Nala Ginrut; +Cc: guile-devel On Tue 18 Oct 2011 16:32, Nala Ginrut <nalaginrut@gmail.com> writes: > -----------------------wrong code------------------------------ > (define (func) > (let ((fp (open-output-file "/tmp/aaa"))) > (eval-string "(write 123 fp)" (current-module)) > )) > -----------------------end code------------------------------------ `fp' is a lexical binding, not a module-level binding. So no, this won't work. You won't be able to get to lexical variables via `eval' (or `eval-string'). Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAPjoZoeUQ7aokEUzeQ1f+Ge1zPOkEQcLgwdTiC5YJtDRR2hrqg@mail.gmail.com>]
* Re: Can't get outside bindings in the string expression with eval-string [not found] ` <CAPjoZoeUQ7aokEUzeQ1f+Ge1zPOkEQcLgwdTiC5YJtDRR2hrqg@mail.gmail.com> @ 2011-10-19 2:22 ` Nala Ginrut 0 siblings, 0 replies; 4+ messages in thread From: Nala Ginrut @ 2011-10-19 2:22 UTC (permalink / raw) To: guile-devel [-- Attachment #1: Type: text/plain, Size: 660 bytes --] On Tue, Oct 18, 2011 at 10:59 PM, Andy Wingo <wingo@pobox.com> wrote: > On Tue 18 Oct 2011 16:32, Nala Ginrut <nalaginrut@gmail.com> writes: > > > -----------------------wrong code------------------------------ > > (define (func) > > (let ((fp (open-output-file "/tmp/aaa"))) > > (eval-string "(write 123 fp)" (current-module)) > > )) > > -----------------------end code------------------------------------ > > `fp' is a lexical binding, not a module-level binding. So no, this > won't work. You won't be able to get to lexical variables via `eval' > (or `eval-string'). > > Andy > -- > http://wingolog.org/ > OK, I'll try another approach. [-- Attachment #2: Type: text/html, Size: 1269 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-19 2:22 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-18 14:32 Can't get outside bindings in the string expression with eval-string Nala Ginrut 2011-10-18 14:42 ` Nala Ginrut 2011-10-18 14:59 ` Andy Wingo [not found] ` <CAPjoZoeUQ7aokEUzeQ1f+Ge1zPOkEQcLgwdTiC5YJtDRR2hrqg@mail.gmail.com> 2011-10-19 2:22 ` Nala Ginrut
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).