<br><br><div class="gmail_quote">2011/3/11 spir <span dir="ltr"><<a href="mailto:denis.spir@gmail.com">denis.spir@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hello,<br>
<br>
Is an environment implemented as plain Scheme data?</blockquote><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> If yes, is the current<br>


environment (I mean the set of currently "lookup-able" symbols) accessible?<br></blockquote><div><br></div><div>Yes.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


Hope I'm clear (don't know yet Scheme's proper vocabulary yet). I'm thinking at<br>
something along the lines of:<br>
     (getSymbolValue env 'a)<br>
beeing equivalent, for a symbol 'a, to:<br>
     (eval 'a)<br></blockquote><div><br></div><div>Gambit has only one environment. It has several namespaces though. The REPL default namespace has the name "~".</div><div><br></div><div>Implement this as:</div>

<div>(define (getSymbolValue sy) (eval (string->symbol (string-append "~#" (symbol->string sy))))</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


and<br>
     (defSymbol env 'a 1)<br>
equivalent to:<br>
     (define a 1)<br></blockquote><div><br></div><div>Someone knows this one better than me.</div><div><br></div><div>Maybe experiment with (define (defSymbol sy value) (eval `(define ,(string->symbol (string-append "~#" (symbol->string sy)) ,value)))) but no idea.</div>

<div> </div><div>Since it's lisp generally you'd spell out the above rather as get-symbol-value and def-symbol! .</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Aside pure reflexivity, this would allow some nice tricks, like unpaking an<br>
associative table into the current env:<br>
     (unpack (parseRecord line))<br>
where parseRecord returns eg a (name phone email) table, would def symbols<br>
under those names in env.<br></blockquote><div><br></div><div>Generally you want to avoid using the global namespace as much as you ever can. You want to use it only as a trampoline for the real work you do. One of the few things you really need to keep there are [library/module] procedures etc. that you intend to reuse over and over.</div>

<div><br></div><div>Mikael</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Denis<br>
--<br>
_________________<br>
vita es estrany<br>
<a href="http://spir.wikidot.com" target="_blank">spir.wikidot.com</a><br>
<br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</blockquote></div><br>