@@ 0,0 1,28 @@
+;; (compile-time-const expr)
+;; eval's expr in the current module and replaces itself with the
+;; result QUOTED.
+;;
+;; Example repl session:
+;; > ,expand (define (test) (compile-time-eval (curent-time)))
+;; $1 = (define (test) 1600362567)
+
+(define-syntax compile-time-const
+ (lambda (stx)
+ (syntax-case stx ()
+ ((_ expr)
+ (let ((thing (eval (syntax->datum #'expr) (current-module))))
+ (display (list? thing))
+ (datum->syntax stx `(quote ,thing)))))))
+
+
+;; define-inline-const. Like compile-time-const, but
+;; binds it to an identifier macro to inline it wherever it is
+;; used. In guile 3 you probably don't need this, since declarative
+;; modules will most certainly inline constants.
+(define-syntax define-inline-const
+ (lambda (stx)
+ (syntax-case stx ()
+ ((_ name val)
+ (let ((thing (eval (syntax->datum #'val) (current-module))))
+ (with-syntax ((val (datum->syntax stx thing)))
+ #'(define-syntax name (identifier-syntax val))))))))