summaryrefslogtreecommitdiff
path: root/src/util.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.lisp')
-rw-r--r--src/util.lisp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util.lisp b/src/util.lisp
new file mode 100644
index 0000000..d58cde8
--- /dev/null
+++ b/src/util.lisp
@@ -0,0 +1,22 @@
+(in-package :monkey)
+
+(defun concat-symbols (sym1 sym2)
+ (intern (format nil "~a-~a" (symbol-name sym1) (symbol-name sym2))))
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defmacro eval-always (&body body)
+ `(eval-when (:compile-toplevel :load-toplevel :execute)
+ ,@body)))
+
+(defun read-file-contents (file-name)
+ (let* ((len 0)
+ (contents
+ (with-output-to-string (out)
+ (with-open-file (in file-name :external-format :utf-8)
+ (loop :with buffer := (make-array 8192 :element-type 'character)
+ :for n := (read-sequence buffer in)
+ :while (< 0 n)
+ :do (incf len n)
+ (write-sequence buffer out :start 0 :end n))))))
+ (values contents len)))
+