records: Make a couple of procedures available at expansion time.
authorLudovic Courtès <ludo@gnu.org>
Thu, 31 May 2018 15:32:22 +0000 (17:32 +0200)
committerLudovic Courtès <ludo@gnu.org>
Thu, 31 May 2018 16:13:08 +0000 (18:13 +0200)
* guix/records.scm (current-abi-identifier, abi-check): Wrap in
'eval-when'.

guix/records.scm

index c71cfcf..da3ecda 100644 (file)
 (set-exception-printer! 'record-abi-mismatch-error
                         print-record-abi-mismatch-error)
 
-(define (current-abi-identifier type)
-  "Return an identifier unhygienically derived from TYPE for use as its
+(eval-when (expand load eval)
+  ;; The procedures below are needed both at run time and at expansion time.
+
+  (define (current-abi-identifier type)
+    "Return an identifier unhygienically derived from TYPE for use as its
 \"current ABI\" variable."
-  (let ((type-name (syntax->datum type)))
-    (datum->syntax
-     type
-     (string->symbol
-      (string-append "% " (symbol->string type-name)
-                     " abi-cookie")))))
-
-(define (abi-check type cookie)
-  "Return syntax that checks that the current \"application binary
+    (let ((type-name (syntax->datum type)))
+      (datum->syntax
+       type
+       (string->symbol
+        (string-append "% " (symbol->string type-name)
+                       " abi-cookie")))))
+
+  (define (abi-check type cookie)
+    "Return syntax that checks that the current \"application binary
 interface\" (ABI) for TYPE is equal to COOKIE."
-  (with-syntax ((current-abi (current-abi-identifier type)))
-    #`(unless (eq? current-abi #,cookie)
-        (throw 'record-abi-mismatch-error #,type))))
+    (with-syntax ((current-abi (current-abi-identifier type)))
+      #`(unless (eq? current-abi #,cookie)
+          (throw 'record-abi-mismatch-error #,type)))))
 
 (define-syntax make-syntactic-constructor
   (syntax-rules ()