1 / 13

Heaps in Scheme

Heaps in Scheme. Heaps in Scheme. Normally, procedure calls are saved on a stack. Heaps in Scheme. Normally, procedure calls are saved on a stack. f (n) { int x = 1; g(x);. f:x=1. Heaps in Scheme. Normally, procedure calls are saved on a stack. g(n) { int x = 2; h(x);.

jessie
Télécharger la présentation

Heaps in Scheme

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Heaps in Scheme

  2. Heaps in Scheme Normally, procedure calls are saved on a stack

  3. Heaps in Scheme Normally, procedure calls are saved on a stack f (n) { int x = 1; g(x); f:x=1

  4. Heaps in Scheme Normally, procedure calls are saved on a stack g(n) { int x = 2; h(x); f (n) { int x = 1; g(x); g:x=2 f:x=1

  5. Heaps in Scheme Normally, procedure calls are saved on a stack g(n) { int x = 2; h(x); h(n) { int x = 3; } f (n) { int x = 1; g(x); g:x=2 f:x=1

  6. Heaps in Scheme Normally, procedure calls are saved on a stack g(n) { int x = 2; h(x); } h(n) { int x = 3; } f (n) { int x = 1; g(x); f:x=1

  7. Heaps in Scheme Normally, procedure calls are saved on a stack g(n) { int x = 2; h(x); } h(n) { int x = 3; } f (n) { int x = 1; g(x); }

  8. Heaps in Scheme But in Scheme a heap is used to save proc state

  9. Heaps in Scheme But in Scheme a heap is used to save proc state (f 1 (g f:1

  10. Heaps in Scheme But in Scheme a heap is used to save proc state (f 1 (g 2 (h (set! c (call/cc (lambda (k) k)) c g:2 f:1

  11. Heaps in Scheme But in Scheme a heap is used to save proc state (f 1 (g 2 (h (set! c (call/cc (lambda (k) k))) c g:2 f:1

  12. Heaps in Scheme But in Scheme a heap is used to save proc state (f 1 (g 2 (h (set! c (call/cc (lambda (k) k))))) (g 3 (h ... c g:3 g:2 f:1

  13. Heaps in Scheme But in Scheme a heap is used to save proc state (f 1 (g 2 (h (set! c (call/cc (lambda (k) k))))) (g 3 (h ... c To return to a previous point in time: (c 4) Has the effect of returning from the set! with value 4 g:3 g:2 f:1

More Related