Questions about SICP 
Author Message
 Questions about SICP

A couple of questions about SICP...

1) The stack based Scheme implementation given at the end of the book
wouldn't seem to work with call/cc would it? I mean with call/cc, you
can have lots of stacks diverging ready to come back into use when
required. The machine in SICP seems to use a single stack, which
wouldn't work.

This is my first reading of the book, so I could be wrong, or I could
be missing something. Comments?

I would seem to me that the stack is best implemented as some
attribute of the environment objects. Comments?

2) Who is the photo of on the back cover?

Chris Bitmead.

--
---------------------------------------------------------------
| Chris Bitmead.....................................9690 5727 |

---------------------------------------------------------------
The sum of the intelligence of the world is constant.  
The population is, of course, growing.



Tue, 17 Aug 1999 03:00:00 GMT  
 Questions about SICP

Quote:

> A couple of questions about SICP...

> 1) The stack based Scheme implementation given at the end of the book
> wouldn't seem to work with call/cc would it? I mean with call/cc, you
> can have lots of stacks diverging ready to come back into use when
> required. The machine in SICP seems to use a single stack, which
> wouldn't work.

> This is my first reading of the book, so I could be wrong, or I could
> be missing something. Comments?

You are right. If call/cc is used in a purely stack-based
implementation the stack must be copied, at least partially, when a
continuation is saved. Kent Dybvig's doct{*filter*}assertion "Three
Implementation Models for Scheme" covers this, at least.

Quote:
> I would seem to me that the stack is best implemented as some
> attribute of the environment objects. Comments?

If your whole "stack" is actually allocated from heap using conses you
don't have any problems because the stack can branch freely. Garbage
collection will then take care of reclaiming popped stack items. Of
course, this is more inefficient than a distinct, linear stack.

Quote:
> 2) Who is the photo of on the back cover?

Isn't it a so-called composite image of the both authors? (Probably to
be read: what you have when you morph from the picture of one to the
picture of other and took what you have at the mid-way.)

--

              * The {*filter*} of Christ cleanses from all sin. *



Tue, 17 Aug 1999 03:00:00 GMT  
 Questions about SICP



|   Subject: Questions about SICP
|   Date: 28 Feb 1997 01:10:42 GMT
|  
|   A couple of questions about SICP...
|  
|   1) The stack based Scheme implementation given at the end of the book
|   wouldn't seem to work with call/cc would it? I mean with call/cc, you
|   can have lots of stacks diverging ready to come back into use when
|   required. The machine in SICP seems to use a single stack, which
|   wouldn't work.
|  
|   This is my first reading of the book, so I could be wrong, or I could
|   be missing something. Comments?
|  
|   I would seem to me that the stack is best implemented as some
|   attribute of the environment objects. Comments?
|  

Unless the implementation in the book has changed a lot recently, the
so-called stack is actually a linked list in the heap, so supporting
cwcc is quite straightforward.

There are a lot of techniques for supporting cwcc with a true stack.
The tradeoffs involve:
- cost of cwcc
- cost of continuation invocation
- cost of state preserving at function calls
- cost of function returns



Fri, 20 Aug 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Question about SICP's query system...

2. Question to SICP, Exercise 3.42

3. SICP question

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

5. SICP for the US & Canada

6. SICP for the US & Canada

7. Spread of Scheme and SICP?

8. SICP again

9. OOP: Java vs. SICP

10. Help me! if you have the book SICP

11. Help needed - Scheme code from SICP

12. Scheme code (SICP)

 

 
Powered by phpBB® Forum Software