Removals
-
All reimplementations of functions in the package Toolz have been removed. Import these from Toolz (or CyToolz) instead. Beware that the Toolz functions are not all drop-in replacements for the old Hy functions; e.g.,
partition
has a different order of parameters.complement
,compose
(formerlycomp
in Hy),drop
,first
,identity
,interleave
,interpose
,iterate
,juxt
,last
,merge-with
,nth
,partition
,second
,take-nth
,take
-
All aliases of objects in Python's standard library have been removed. Import these objects explicitly instead.
- From
itertools
:accumulate
,chain
,combinations-with-replacement
(formerlymulticombinations
in Hy),combinations
,compress
,count
,cycle
,dropwhile
(formerlydrop-while
),filterfalse
(formerlyremove
),groupby
(formerlygroup-by
),islice
,permutations
,product
,repeat
,starmap
(formerly*map
),takewhile
(formerlytake-while
),tee
,zip-longest
- From
functools
:reduce
- From
fractions
:Fraction
(formerlyfraction
)
- From
-
The following core predicate functions have been removed. Use
isinstance
etc. instead.empty?
,even?
,every?
,float?
,integer-char?
,integer?
,iterable?
,iterator?
,keyword?
,list?
,neg?
,none?
,numeric?
,odd?
,pos?
,some
,string?
,symbol?
,tuple?
,zero?
-
Several other core functions and macros have been removed:
keyword
: Use(hy.models.Keyword (hy.unmangle …))
instead.repeatedly
: Usetoolz.iterate
instead.if-not
: Use(if (not …) …)
instead.lif-not
: Use(lif (not …) …)
instead.macro-error
: Useraise
instead.calling-module
: Now internal to Hy.calling-module-name
: Now internal to Hy.
Other Breaking Changes
-
if
no longer allows more than three arguments. Usecond
instead. -
cut
with exactly two arguments (the object to be cut and the index) now works like Python slicing syntax and theslice
function:(cut x n)
gets the firstn
elements instead of everything after the firstn
. -
In
defn
, the return-value annotation, if any, is now placed before the function name instead of after. -
Python reserved words are no longer allowed as parameter names, nor as keywords in keyword function calls.
-
Hy model objects are no longer equal to ordinary Python values. For example,
(!= 1 '1)
. You can promote values to models withhy.as-model
before making such a check. -
The following functions are now called as attributes of the
hy
module:hy.disassemble
,hy.gensym
,hy.macroexpand
,hy.macroexpand-1
,hy.repr
(formerlyhy.contrib.hy-repr.hy-repr
),hy.repr-register
(formerlyhy.contrib.hy-repr.hy-repr-register
)
-
cmp
has been renamed tochainc
. -
defclass
no longer automatically addsNone
to the end of__init__
method definitions. -
All special forms have been replaced with macros. This won't affect most preexisting code, but it does mean that user-defined macros can now shadow names like
setv
. -
hy.repr
no longer uses the registered method of a supertype. -
The constructors of
Symbol
andKeyword
now check that the input would be syntactically legal. -
Attempting to call a core macro not implemented on the current version of Python is now an error.
-
hy.extra.reserved.special
has been replaced withhy.extra.reserved.macros
.
New Features
hy-repr
is now the default REPL output function.- The command
python -m hy
now works the same ashy
. - New function
hy.as-model
. - New macro
match
(Python 3.10 only). annotate
is now a user-visible macro.
Bug Fixes
- Fixed issues with newer prereleases of Python 3.10.
- The REPL now properly displays
SyntaxError
s. - Fixed a bug in
pprint
in whichwidth
was ignored. - Corrected
repr
andhy.repr
for f-strings. --spy
and--repl-output-fn
can now overwriteHYSTARTUP
values.