chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken s


From: Sungjin Chun
Subject: [Chicken-users] [Q] How can I convert this lisp(SBCL) macro to chicken scheme?
Date: Fri, 7 Nov 2014 10:17:26 +0900

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]