hy/tests/native_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
..
contrib Move anaphoric macros to contrib module 2013-11-28 23:53:02 -05:00
__init__.hy ideas, ideas. 2013-03-05 18:39:34 -05:00
core.hy Adding automatic gensym macro 2013-12-15 18:47:46 -07:00
defclass.hy Fix missing docstrings from defclass issue #248 2013-07-15 06:58:08 -06:00
language.hy Merge branch 'paultag/feature/support-question-marks' of https://github.com/paultag/hy into paultag-paultag/feature/support-question-marks 2013-12-05 19:28:59 +01:00
math.hy Int conversion to long in py2.x 2013-10-11 01:49:42 +02:00
native_macros.hy Adding automatic gensym macro 2013-12-15 18:47:46 -07:00
quote.hy Add test for unquote-splice behavior 2013-09-22 15:12:59 +02:00
unless.hy Add a `unless' macro 2013-04-28 17:04:35 +02:00
when.hy Add a `when' macro 2013-04-28 17:04:35 +02:00
with_decorator.hy Rename decorate-with' to with-decorator' 2013-04-28 17:14:22 +02:00