call/cc seems to be working!
authorTim Vaughan <tgvaughan@gmail.com>
Wed, 1 Aug 2018 14:40:04 +0000 (16:40 +0200)
committerTim Vaughan <tgvaughan@gmail.com>
Wed, 1 Aug 2018 14:40:04 +0000 (16:40 +0200)
src/scheme-primitives.4th
src/scheme.4th

index f6bb92d..a9b4741 100644 (file)
@@ -607,9 +607,17 @@ defer display
     2swap apply
 ; make-primitive apply 
 
-:noname ( args -- result )
-  make-continuation nil cons
-  2swap apply
+:noname ( proc -- result )
+    make-continuation
+
+    drop if
+        nil cons
+        2swap apply
+    else
+        2swap 2drop
+    then
+
+    trace
 
 ; 1 make-fa-primitive call-with-current-continuation
 
index 36a8106..9d64667 100644 (file)
@@ -551,11 +551,16 @@ global-env obj!
   depth 2- 2/ fixnum-type 2swap cons
 ;
 
-: make-continuation
+: make-continuation ( -- continuation true-obj )
+    \ true-obj allows calling code to detect whether
+    \ it is being called immediately following make-continuation
+    \ or by a restore-continuation.
 
   cons-param-stack
   cons-return-stack
   cons drop continuation-type
+
+  true boolean-type
 ;
 
 : continuation->pstack-list
@@ -627,6 +632,10 @@ global-env obj!
 
     2swap
 
+    false boolean-type \ Add flag signifying continuation restore
+
+    2swap
+
     restore-return-stack
 ;