This release is a direct successor to 1.0a4. We've returned to 0.* version numbers to work around the inflexibility of PyPI and pip regarding the default version to install. (We skipped some version numbers because this release is several major releases since 0.20.0.) Sorry for the mess.
Removals
- Tag macros have been removed. Use reader macros instead, rewriting
(defmacro "#foo" [arg] …)
as(defreader foo (setv arg (.parse-one-form &reader)) …)
. with-decorator
and#@
have been removed in favor of decorator lists (see below).- Fraction literals have been removed. Use
fractions.Fraction
instead. - Unrecognized backslash escapes in string and byte literals are no longer allowed. (They've been deprecated in Python since 3.6.)
- A bare
#
is no longer a legal symbol. u
is no longer allowed as a string prefix. (It had no effect, anyway.)hy.read-str
has been removed. Usehy.read
, which now accepts strings, instead.
Other Breaking Changes
-
Tuples are now indicated with
#( … )
, as in#(1 2 3)
, instead of(, … )
, as in(, 1 2 3)
. -
Tuples have their own model type,
hy.models.Tuple
, instead of being represented asExpression
\s. -
if
now requires all three arguments. For the two-argument case (i.e., with no else-clause),when
is a drop-in replacement. -
cond
has a new unbracketed syntax:(cond [a b] [x y z]) ; Old (cond a b x (do y z)) ; New
-
defmacro
once again requires the macro name as a symbol, not a string literal. -
Annotations are now indicated by
#^
instead of^
. -
annotate
(but not#^
) now takes the target first and the type second, as in(annotate x int)
. -
The way f-strings are parsed has changed, such that unescaped double quotes are now allowed inside replacement fields.
-
Non-ASCII whitespace is no longer ignored during tokenization like ASCII whitespace.
-
The mangling rules have been refined to account for Python's treatment of distinct names as referring to the same variable if they're NFKC-equivalent. Very little real code should be affected.
-
hy.cmdline.run_repl
has been replaced withhy.cmdline.HyREPL.run
.
Bug Fixes
- Fixed a crash when using keyword objects in
match
. - Fixed a scoping bug in comprehensions in
let
bodies. - Literal newlines (of all three styles) are now recognized properly in string and bytes literals.
defmacro
no longer allows further arguments after#* args
.!=
with model objects is now consistent with=
.- Tracebacks from code parsed with
hy.read
now show source positions. - Elements of
builtins
such ashelp
are no longer overridden until the REPL actually starts. - Readline is now imported only when necessary, to avoid triggering a CPython bug regarding the standard module
curses
(cpython#46927). - Module names supplied to
hy -m
are now mangled. - Hy now precompiles its own Hy code during installation.
New Features
-
Added user-defined reader macros, defined with
defreader
. -
defn
anddefclass
now allow a decorator list as their first argument. -
...
is now understood to refer toEllipsis
, as in Python. -
Python reserved words are allowed once more as parameter names and keyword arguments. Hy includes a workaround for a CPython bug that prevents the generation of legal Python code for these cases (cpython#90678).
-
New macro
export
.- Or you can set the variable
_hy_export_macros
to control what macros are collected by(require module *)
.
- Or you can set the variable
-
New macro
delmacro
. -
New function
hy.read_many
. -
New function
hy.model_patterns.parse_if
. -
New function
hy.model_patterns.in_tuple
. -
Added a command-line option
-u
(or--unbuffered
) per CPython. -
Tab-completion in the REPL now attempts to unmangle names.