Hi,

I've rather impressed on Clojure's easy to use hash and vector/array, I've
written
and used these macros in my lisp code. Now I want to convert them for
chicken.

(set-macro-character
  #\{
  (lambda (stream char)
    (declare (ignore char))
    (let ((*readtable* (copy-readtable *readtable* nil)))
      (set-macro-character #\} (get-macro-character #\)))
      (set-macro-character #\, (lambda (stream char)
                                 (declare (ignore stream char))
                                 (values)))
      (set-macro-character #\~ (get-macro-character #\,))
      (let ((contents (read-delimited-list #\} stream t))
            (ht (gensym)))
        `(let ((,ht (make-hash-table :test #'equal :synchronized t)))
           ,@(loop for (k v) on contents by #'cddr
                collect `(setf (gethash ,k ,ht) ,v))
           ,ht)))))

(set-macro-character
  #\[
  (lambda (stream char)
    (declare (ignore char))
    (let ((*readtable* (copy-readtable *readtable* nil)))
      (set-macro-character #\] (get-macro-character #\)))
      (set-macro-character #\, (lambda (stream char)
                                 (declare (ignore stream char))
                                 (values)))
      (set-macro-character #\~ (get-macro-character #\,))
      (let ((contents (read-delimited-list #\] stream t)))
        `(vector ,@contents)))))

How can I convert this macros to chicken, where can I find introductory
docs on macro
of chicken scheme?

Thank you in advance.
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to