Question about SICP's query system... 
Author Message
 Question about SICP's query system...

  Back again with another question concerning SICP's query system.

In the 'instantiate' predicate, I have a problem with (or don't understand)
what is going on with the vcell variable.  In this predicate, vcell is
set to something (whatever binding-in-frame returns) then we ask if vcell
is empty.  If so, we then do the unbound-var-handlers and call copy
recursively on the binding-value of vcell.  My problem is this, if we have
just tested vcell to be empty then how can we take the cdr of vcell, an
empty list (which is what binding-value does)??

--
--------------------------------------------------------------------------



Fri, 21 Oct 1994 04:07:23 GMT  
 Question about SICP's query system...

Quote:

>  My problem is this, if we have
>just tested vcell to be empty then how can we take the cdr of vcell, an
>empty list (which is what binding-value does)??

You just read the code too fast.  The call to binding-value is in the
third argument to IF, i.e., the one that gets evaluated if the condition
is *false*!  You're reading it as if it said

(if (null? vcell)
    (sequence (unbound-var-handler ...)
              (copy ...) ))

but it doesn't say "sequence."



Fri, 21 Oct 1994 21:36:31 GMT  
 Question about SICP's query system...

moritz> Back again with another question concerning SICP's query
moritz> system.

moritz> In the 'instantiate' predicate, I have a problem with (or
moritz> don't understand) what is going on with the vcell variable.
moritz> In this predicate, vcell is set to something (whatever
moritz> binding-in-frame returns) then we ask if vcell is empty.  If
moritz> so, we then do the unbound-var-handlers and call copy
moritz> recursively on the binding-value of vcell.  My problem is
moritz> this, if we have just tested vcell to be empty then how can we
moritz> take the cdr of vcell, an empty list (which is what
moritz> binding-value does)??

You're not reading the code correctly or you're mixed up about the
semantics of `if':

        (if (null? vcell)
            (unbound-var-handler exp frame)
            (copy (binding-value vcell)))

(unbound-var-handler exp frame) is evaluated if vcell is null.
(copy (binding-value vcell)) is only evaluated if vcell in non-null.

--

Department of Computer Science          (603) 862-3786
University of New Hampshire
Durham, NH 03824



Fri, 21 Oct 1994 22:29:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. SICP query lang. compiler

2. SICP 'picture language'

3. SICP 'Picture Language' rogers image

4. 'system' and variables (newbie question)

5. Is SICP a better intro than `SAP'?

6. MySQL query in PHP: Not query zero amounts also removes null amounts from query

7. Question about Mindy's system method

8. Questions about SICP

9. SICP question

10. Question to SICP, Exercise 3.42

11. SICP (2Ed) Ch. 5 question?...

12. Regina stream('Query exists') bug

 

 
Powered by phpBB® Forum Software