]> gitweb.factorcode.org Git - factor.git/commitdiff
syntax: change STARTUP-HOOK: and SHUTDOWN-HOOK:
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 25 Jan 2022 17:32:10 +0000 (09:32 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 25 Jan 2022 17:32:10 +0000 (09:32 -0800)
instead of parse-definition:

    STARTUP-HOOK: ... ;

we parse a startup-word or a quotation:

    STARTUP-HOOK: do-startup

    STARTUP-HOOK: [ do-startup ]

this is somewhat experimental syntax and we might change it further

core/syntax/syntax.factor

index 0ce8ec2871f46a7e33cc04c9dda093391dc4adc8..7f48f5fc435fe0bb4f28f5071dd302e2e19a1329 100644 (file)
@@ -336,12 +336,14 @@ IN: bootstrap.syntax
     "IDENTITY-MEMO::" [ (::) define-identity-memoized ] define-core-syntax
 
     "STARTUP-HOOK:" [
-        \ ; parse-until >quotation current-vocab name>>
-        add-startup-hook
+        scan-word
+        dup \ [ = [ drop parse-quotation ] [ 1quotation ] if
+        current-vocab name>> [ add-startup-hook ] 2curry append!
     ] define-core-syntax
 
     "SHUTDOWN-HOOK:" [
-        \ ; parse-until >quotation current-vocab name>>
-        add-shutdown-hook
+        scan-word
+        dup \ [ = [ drop parse-quotation ] [ 1quotation ] if
+        current-vocab name>> [ add-shutdown-hook ] 2curry append!
     ] define-core-syntax
 ] with-compilation-unit