]> gitweb.factorcode.org Git - factor.git/commitdiff
continuations: add a throw-continue word for resumable errors, and change vocabs...
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 20 Feb 2010 00:41:33 +0000 (13:41 +1300)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 20 Feb 2010 00:41:33 +0000 (13:41 +1300)
basis/vocabs/metadata/metadata.factor
core/compiler/units/units.factor
core/continuations/continuations-docs.factor
core/continuations/continuations.factor

index 10e4eac2a2e11e7bf71583525379dff6a903788b..09ca012fcc0ed7f02bc6e597a2f7af402ae8bc42 100644 (file)
@@ -100,19 +100,24 @@ ERROR: bad-platform name ;
     [ [ name>> ] map ] dip
     dup vocab-platforms-path set-vocab-file-contents ;
 
-: supported-platform? ( vocab -- ? )
-    vocab-platforms [ t ] [ [ os swap class<= ] any? ] if-empty ;
+: supported-platform? ( platforms -- ? )
+    [ t ] [ [ os swap class<= ] any? ] if-empty ;
 
 : unportable? ( vocab -- ? )
     {
         [ vocab-tags "untested" swap member? ]
-        [ supported-platform? not ]
+        [ vocab-platforms supported-platform? not ]
     } 1|| ;
 
-ERROR: unsupported-platform vocab ;
+TUPLE: unsupported-platform vocab requires ;
+
+: unsupported-platform ( vocab requires -- )
+    \ unsupported-platform boa throw-continue ;
 
 M: unsupported-platform summary
     drop "Current operating system not supported by this vocabulary" ;
 
-[ dup supported-platform? [ drop ] [ vocab-name unsupported-platform ] if ]
-check-vocab-hook set-global
+[
+    dup vocab-platforms dup supported-platform?
+    [ 2drop ] [ [ vocab-name ] dip unsupported-platform ] if
+] check-vocab-hook set-global
index 9582ebadb6e3d54bb8318fde5ca3b24d8a03b677..b024ed2c65c4b7843c176d28d845a085c7dc8d75 100644 (file)
@@ -12,8 +12,7 @@ SYMBOL: new-definitions
 TUPLE: redefine-error def ;
 
 : redefine-error ( definition -- )
-    \ redefine-error boa
-    { { "Continue" t } } throw-restarts drop ;
+    \ redefine-error boa throw-continue ;
 
 <PRIVATE
 
index 84da26a0821a46e6c36b67769a51b53da492ce00..766a78c483970d47b40bc57f1f1f04e447a7ee8e 100644 (file)
@@ -9,9 +9,13 @@ ARTICLE: "errors-restartable" "Restartable errors"
     throw-restarts
     rethrow-restarts
 }
+"A utility word using the above:"
+{ $subsections
+    throw-continue
+}
 "The list of restarts from the most recently-thrown error is stored in a global variable:"
 { $subsections restarts }
-"To invoke restarts, see " { $link "debugger" } "." ;
+"To invoke restarts, use " { $link "debugger" } "." ;
 
 ARTICLE: "errors-post-mortem" "Post-mortem error inspection"
 "The most recently thrown error, together with the continuation at that point, are stored in a pair of global variables:"
@@ -213,7 +217,11 @@ HELP: rethrow-restarts
 { $values { "error" object } { "restarts" "a sequence of " { $snippet "{ string object }" } " pairs" } { "restart" object } }
 { $description "Throws a restartable error using " { $link rethrow } ". Otherwise, this word is identical to " { $link throw-restarts } "." } ;
 
-{ throw rethrow throw-restarts rethrow-restarts } related-words
+{ throw rethrow throw-restarts rethrow-restarts throw-continue } related-words
+
+HELP: throw-continue
+{ $values { "error" object } }
+{ $description "Throws a resumable error. If the user elects to continue execution, this word returns normally." } ;
 
 HELP: compute-restarts
 { $values { "error" object } { "seq" "a sequence" } }
index d63acae8836213fbbef3ae6ad5431717f06e55fa..332354e302ed706b0f938057a8c4ae359cd8d08c 100644 (file)
@@ -149,6 +149,9 @@ C: <condition> condition ( error restarts cc -- condition )
 : rethrow-restarts ( error restarts -- restart )
     [ <condition> rethrow ] callcc1 2nip ;
 
+: throw-continue ( error -- )
+    { { "Continue" t } } throw-restarts drop ;
+
 TUPLE: restart name obj continuation ;
 
 C: <restart> restart