hy/tests
Bob Tolbert c80e3c75a0 Adding automatic gensym macro
Adding to the manual gensym for macros are 2 new
macros, but very literal from the CL in
letoverlambda.

The first is the (with-gensyms ...) macro that
can generate a small set of syms for a macro. Works
something like:

(defmacro adder2 [A B]
  (with-gensyms [a b]
    `(let [[~a ~A] [~b ~B]]
       (+ ~a ~b))))

and ~a and ~b will be replaced with (gensym "a") and
(gensym "b") respectively.

Then the final macro is a new defmacro that will automatically
replace symbols prefaced with "g!" with a new gensym based on the
rest of the symbol. So in this final version of 'nif':

(defmacro/g! nif4 (expr pos zero neg)
  `(let [[~g!result ~expr]]
     (cond [(pos? ~g!result) ~pos]
           [(zero? ~g!result) ~zero]
           [(neg? ~g!result) ~neg])))

all uses of ~g!result will be replaced with (gensym "result").
2013-12-15 18:47:46 -07:00
..
compilers Always import __future__.print_statement in hy code 2013-09-22 15:31:15 +02:00
importer Fix flake error 2013-07-06 20:39:02 +02:00
lex Wire the rply parser 2013-07-28 17:36:36 +02:00
macros Cleanup the hy.macros module 2013-09-29 18:13:28 +02:00
models Make HyList add returns HyList 2013-04-28 17:04:33 +02:00
native_tests Adding automatic gensym macro 2013-12-15 18:47:46 -07:00
resources Rewrite the bootstrap macros in hy 2013-09-29 18:13:28 +02:00
__init__.py Add set of new core functions 2013-07-13 09:55:16 -06:00
test_bin.py Merge pull request #328 from berkerpeksag/add-astor 2013-12-11 08:13:03 -08:00