(let ((static)) (setq static (dlambda (:create-indices (length) (call static :create-indices-tail (- length 1) ())) (:create-indices-tail (index accumulator) (if (< index 0) accumulator (recur (- index 1) (cons index accumulator)))))) (defmacro array (length) (let* ((this (gensym)) (index-prefix (fuse this 'index)) (indices (call static :create-indices length)) (index-bindings (map (lambda (i) `(,(fuse index-prefix i))) indices)) (scope `((,this) ,@index-bindings))) `(let ,scope (setq ,this (dlambda (:get (i) (eval (fuse ',index-prefix i))) (:set (i value) (if (and (< i ,length) (> i -1)) (set (fuse ',index-prefix i) value) (call ,this :get i))) ;; show error (:length () ,length) (t () ((lambda (length accumulator) (if (< length 1) accumulator (recur (- length 1) (cons (call ,this :get (- length 1)) accumulator)))) ,length nil))))))))