Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After more digging around I discovered this <a href="http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/78ee853ca52c84fd/6a452d426eab0e53?lnk=gst&amp;q=make-environment#6a452d426eab0e53" rel="noreferrer">informative thread</a> on newsnet:</p> <p>"The R5RS EVAL and environment specifiers are a compromise between those who profoundly dislike first-class environments and want a restricted EVAL, and those who can not accept/understand EVAL without a second argument that is an environment."</p> <p>Also, found this "work-around":</p> <pre><code>(define-syntax make-environment (syntax-rules () ((_ definition ...) (let ((environment (scheme-report-environment 5))) (eval '(begin definition ...) environment) environment)))) (define arctic (make-environment (define animal 'polarbaer))) </code></pre> <p>(taken from <a href="http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/b083c43f0f1545e1/37ebb30db69cd507?lnk=gst&amp;q=make-environment#37ebb30db69cd507" rel="noreferrer">this</a>)</p> <p>However, I ended up adopting a "message passing" style kinda of like the first guy suggested - I return an alist of functions, and have a generic "send" method for invoking a particular function by name... i.e something like this</p> <pre><code>(define multiply (list (cons 'differentiate (...)) (cons 'evaluate (lambda (args) (apply * args))))) (define lookup (lambda (name dict) (cdr (assoc name dict)))) ; Lookup the method on the object and invoke it (define send (lambda (method arg args) ((lookup method arg) args)) ((send 'evaluate multiply) args) </code></pre> <p>I've been reading further and am aware that there's all of CLOS if I really wanted to adopt a fully OO style - but I think even above is somewhat overkill.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload