Merge pull request #1003 from algernon/f/defreader-1-string

defreader: Allow strings as macro names
This commit is contained in:
Ryan Gonzalez 2016-04-14 12:13:00 -05:00
commit a0251a25ed
2 changed files with 10 additions and 1 deletions

View File

@ -2467,7 +2467,7 @@ class HyASTCompiler(object):
NOT_READERS = [":", "&"]
if name in NOT_READERS or len(name) > 1:
raise NameError("%s can't be used as a macro reader symbol" % name)
if not isinstance(name, HySymbol):
if not isinstance(name, HySymbol) and not isinstance(name, HyString):
raise HyTypeError(name,
("received a `%s' instead of a symbol "
"for reader macro name" % type(name).__name__))

View File

@ -37,6 +37,15 @@
(assert (= (, 1 2 3) a)))
(defn test-reader-macro-string-name []
"Test if defreader accepts a string as a macro name."
(defreader "." [expr]
expr)
(assert (= #."works" "works")))
(defn test-builtin-decorator-reader []
(defn increment-arguments [func]
"Increments each argument passed to the decorated function."