Skip to content

Releases: hylang/hy

0.28.0

05 Jan 15:06
eae2622
Compare
Choose a tag to compare

Removals

  • doc has been removed. Use (help (get-macro foo)) or (help (get-macro :reader foo)) instead.
  • delmacro has been removed. Use (eval-when-compile (del (get _hy_macros (hy.mangle "foo")))) instead.
  • hy.reserved has been removed. Use (.keys (builtins._hy_macros)) or Python's built-in keyword module instead.
  • The environment variables HY_DEBUG and HY_FILTER_INTERNAL_ERRORS have been replaced with HY_SHOW_INTERNAL_ERRORS.

Other Breaking Changes

  • defmacro and require can now define macros locally instead of only module-wide.
  • When a macro is require\d from another module, that module is no longer implicitly included when checking for further macros in the expansion.
  • hy.M has been renamed to hy.I.
  • hy.eval has been overhauled to be more like Python's eval. It also has a new parameter macros.
  • hy.macroexpand and hy.macroexpand-1 have been overhauled and generalized to include more of the features of hy.eval.
  • hy now only implicitly launches a REPL if standard input is a TTY.
  • hy -i has been overhauled to work as a flag like python3 -i.
  • hy2py now requires -m to specify modules, and uses the same sys.path rules as Python when parsing a module vs a standalone script.
  • New macro deftype.
  • New macro get-macro.
  • New macro local-macros.

New Features

  • New syntax (hy.R.aaa/bbb.m …) for calling the macro m from the module aaa.bbb without bringing m or aaa.bbb into scope.
  • nonlocal now also works for globally defined names.
  • defn, defn/a, and defclass now support type parameters.
  • HyReader now has an optional parameter to install existing reader macros from the calling module.
  • New pragma warn-on-core-shadow.

Misc. Improvements

  • Some syntax errors raised by core macros now have more informative messages.
  • Logical operators now compile to simpler Python code in some cases.

Bug Fixes

  • Implicit returns are now disabled in async generators.
  • Fixed parsing of infinite and NaN imaginary literals with an uppercase "J".
  • Double quotes inside of bracketed f-strings are now properly handled.
  • Fixed incomplete recognition of macro calls with a unary dotted head like ((. defn) f []).
  • ~@ #* now produces a syntax error instead of a nonsensical result.
  • nonlocal now works for top-level let-bound names.
  • require now warns when you shadow a core macro, like defmacro already did.
  • Fixed hy.eval failing on defreader or require forms that install a new reader.
  • The parameter result-ok that was mistakenly included in the signature of hy.macroexpand is now gone.
  • hy -i with a filename now skips shebang lines.

0.27.0

06 Jul 19:38
Compare
Choose a tag to compare

Removals

  • Python 3.7 is no longer supported.

Other Breaking Changes

  • Reader macros now always read a full identifier after the initial #. Thus, #*foo is now parsed as a call to the reader macro named *foo; to unpack a variable named foo, say #* foo.
  • The names of reader macros names are no longer mangled.
  • Question marks (?) are no longer mangled specially, so foo? now mangles to hyx_fooXquestion_markX instead of is_foo.
  • hy2py's recursive mode now expects a module name as input, not any old directory. You must be in the parent directory of the module directory.

New Features

  • Python 3.12 is now supported.
  • New built-in object hy.M for easy imports in macros.
  • cut now has a function version in hy.pyops.
  • The py macro now implicitly parenthesizes the input code, so Python's indentation restrictions don't apply.
  • try no longer requires except, except*, or finally, and it allows else even without except or except*.
  • nonlocal and global can now be called with no arguments, in which case they're no-ops.
  • For easier reading, hy --spy now prints a delimiter after the Python equivalent of your code, before the result of evaluating the code.

Bug Fixes

  • Fixed an installation failure in some situations when version lookup fails.
  • Fixed some bugs with traceback pointing.
  • Fixed some bugs with escaping in bracket f-strings
  • The parser no longer looks for shebangs in the REPL or hy -c.
  • require with relative module names should now work correctly with hy -m, as well as hy2py's recursive mode.
  • hy.models.Symbol no longer allows constructing a symbol beginning with #.

0.26.0

08 Feb 18:42
58a870e
Compare
Choose a tag to compare

Removals

  • Coloring error messages and Python representations for models is no longer supported. (Thus, Hy no longer depends on colorama.)

Other Breaking Changes

  • Various warts have been smoothed over in the syntax of ', `, ~, and ~@:

    • Whitespace is now allowed after these syntactic elements. Thus one can apply ~ to a symbol whose name begins with "@".
    • ` and ~ are no longer allowed in identifiers. (This was already the case for '.)
    • The bitwise NOT operator ~ has been renamed to bnot.
  • Dotted identifiers like foo.bar and .sqrt now parse as expressions (like (. foo bar) and (. None sqrt)) instead of symbols. Some odd cases like foo. and foo..bar are now syntactically illegal.

  • New macro do-mac.

  • New macro pragma (although it doesn't do anything useful yet).

  • hy.cmdline.HyREPL is now hy.REPL.

  • Redundant scripts named hy3, hyc3, and hy2py3 are no longer installed. Use hy, hyc, and hy2py instead.

New Features

  • Pyodide is now officially supported.
  • ., .., etc. are now usable as ordinary symbols (with the remaining special rule that ... compiles to Ellipsis).
  • On Pythons ≥ 3.7, Hy modules can now be imported from ZIP archives in the same way as Python modules, via zipimport_.
  • hy2py has a new command-line option --output.
  • hy2py can now operate recursively on a directory.

Bug Fixes

  • hy.REPL now restores the global values it changes (such as sys.ps1) after hy.REPL.run terminates.
  • hy.REPL no longer mixes up Hy's and Python's Readline histories when run inside Python's REPL.
  • Fixed hy.repr of non-compilable uses of sugared macros, such as (quote) and (quote 1 2).

0.25.0

08 Nov 18:08
04866e5
Compare
Choose a tag to compare

Breaking Changes

  • dfor no longer requires brackets around its final arguments, so (dfor x (range 5) [x (* 2 x)]) is now (dfor x (range 5) x (* 2 x)).
  • except* (PEP 654) is now recognized in try, and a placeholder macro for except* has been added.

New Features

  • Python 3.11 is now supported.

Bug Fixes

  • __file__ should now be set the same way as in Python.
  • \N{…} escape sequences are now recognized in f-strings.
  • Fixed a bug with python -O where assertions were still partly evaluated.
  • Fixed hy.repr of slice objects with non-integer arguments.

Misc. Improvements

  • hyc now requires a command-line argument.
  • hyc prints each path it writes bytecode to, and its messages now go to standard error instead of standard output.

0.24.0

23 Jun 14:10
e375827
Compare
Choose a tag to compare

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. Use hy.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 as Expression\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 with hy.cmdline.HyREPL.run.

New Features

  • Added user-defined reader macros, defined with defreader.

  • defn and defclass now allow a decorator list as their first argument.

  • ... is now understood to refer to Ellipsis, 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 *).
  • 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.

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 as help 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.

1.0a4

09 Jan 19:29
699640f
Compare
Choose a tag to compare

Removals

  • Python 3.6 is no longer supported.

Other Breaking Changes

  • import and require no longer need outer brackets. (import [foo [bar]]) is now (import foo [bar]) and (import [foo :as baz]) is now (import foo :as baz). To import all names from a module, use (import foo *).

  • Lots of objects (listed below) have been spun off to a new package called Hyrule, from which you can import or require them. Thus Hy now brings only the hy module and a limited set of core macros into scope automatically.

    • Functions: butlast, coll?, constantly, dec, destructure, distinct, drop-last, end-sequence, flatten, inc, macroexpand-all, parse-args, pformat, postwalk, pp, pprint, prewalk, readable?, recursive?, rest, saferepr, walk
    • Classes: PrettyPrinter, Sequence
    • Macros: #%, #:, ->, ->>, ap-dotimes, ap-each, ap-each-while, ap-filter, ap-first, ap-if, ap-last, ap-map, ap-map-when, ap-reduce, ap-reject, as->, assoc, cfor, comment, defmacro!, defmacro/g!, defmain, defn+, defn/a+, defseq, dict=:, do-n, doto, fn+, fn/a+, ifp, let+, lif, list-n, loop, ncut, of, profile/calls, profile/cpu, seq, setv+, smacrolet, unless, with-gensyms
  • Functions that provide first-class Python operators, such as + in constructs like (reduce + xs), are no longer brought into scope automatically. Say (import hy.pyops *) to get them.

  • Hy scoping rules more closely follow Python scoping in certain edge cases.

  • let is now a core macro with somewhat different semantics. In particular, definition-like core macros (defn, defclass, import) now introduce new names that shadow corresponding let-bound names and persist outside the body of the let.

  • The constructors of String and FString now check that the input would be syntactically legal as a literal.

  • hy.extra.reserved has been renamed to hy.reserved.

New Features

  • hy.repr now supports several more standard types.
  • The attribute access macro . now allows method calls. For example, (. x (f a)) is equivalent to (x.f a).
  • hy.as-model checks for self-references in its argument.
  • New function hy.model_patterns.keepsym.

Bug Fixes

  • In comprehension forms other than for, assignments (other than :setv and loop clauses) are now always visible in the surrounding scope.
  • match now only evaluates the subject once.
  • let will no longer re-evaluate the default arguments of a
    function it's used in.
  • hy.repr now properly formats bracket strings.
  • The repr and str of string models now include brackets if necessary.
  • When standard output can't accommodate Unicode, hy2py now crashes instead of emitting incorrect Python code.
  • Fixed a bug with self-requiring files on Windows.
  • Improved error messages for illegal uses of finally and else.

1.0a3

09 Jul 17:08
Compare
Choose a tag to compare

Bug Fixes

  • Fixed a dependency-management bug that prevented installation of Hy from a wheel on Pythons < 3.9.

1.0a2

07 Jul 18:01
7fe4923
Compare
Choose a tag to compare

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 (formerly comp 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 (formerly multicombinations in Hy), combinations, compress, count, cycle, dropwhile (formerly drop-while), filterfalse (formerly remove), groupby (formerly group-by), islice, permutations, product, repeat, starmap (formerly *map), takewhile (formerly take-while), tee, zip-longest
    • From functools: reduce
    • From fractions: Fraction (formerly fraction)
  • 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: Use toolz.iterate instead.
    • if-not: Use (if (not …) …) instead.
    • lif-not: Use (lif (not …) …) instead.
    • macro-error: Use raise 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. Use cond instead.

  • cut with exactly two arguments (the object to be cut and the index) now works like Python slicing syntax and the slice function: (cut x n) gets the first n elements instead of everything after the first n.

  • 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 with hy.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 (formerly hy.contrib.hy-repr.hy-repr), hy.repr-register (formerly hy.contrib.hy-repr.hy-repr-register)
  • cmp has been renamed to chainc.

  • defclass no longer automatically adds None 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 and Keyword 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 with hy.extra.reserved.macros.

New Features

  • hy-repr is now the default REPL output function.
  • The command python -m hy now works the same as hy.
  • 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 SyntaxErrors.
  • Fixed a bug in pprint in which width was ignored.
  • Corrected repr and hy.repr for f-strings.
  • --spy and --repl-output-fn can now overwrite HYSTARTUP values.

1.0a1

17 Apr 13:40
2d3af2a
Compare
Choose a tag to compare

Removals

  • The core function name has been removed. Use unmangle or the name attribute of keyword objects instead.
  • deftag has been removed. Instead of (deftag foo …), say (defmacro "#foo" …).
  • #doc has been removed. Instead of #doc @, say (doc "#@").
  • __tags__ has been removed. Tag macros are now tracked in __macros__.

Other Breaking Changes

  • Lambda lists (function parameter lists) have been simplified. &optional is gone, &args is #*, &kwargs is #**, and &kwonly is *. Thus, [a &optional b [c 3] &rest args &kwargs kwargs] is now [a [b None] [c 3] #* args #** kwargs].
  • Hy models have been renamed to remove "Hy", and are no longer automatically brought into scope. Thus, HyList is now hy.models.List.
  • eval is no longer automatically brought into scope. Call it as hy.eval (or import it explicitly).
  • Calling a keyword object now does a string lookup, instead of a keyword-object lookup. Thus, (:key obj) is equivalent to (get obj (mangle (. :key name))).
  • To require a tag macro foo, instead of (require [module [foo]]), you must now say (require [module ["#foo"]]).
  • Mangling no longer converts leading hyphens to underscores, and unmangling no longer converts leading underscores to hyphens.
  • F-strings now have their own model type, and store their code parts as models instead of strings.

New Features

  • Python 3.10 is now supported.
  • Lambda lists now support positional-only arguments.
  • F-strings now support = syntax per Python.
  • with now supports unnamed context managers.
  • defmacro and require can now take macro names as string literals.
  • New standard macros do-n, list-n, and cfor.
  • The location of the REPL history file can now be set with the environment variable HY_HISTORY.
  • REPL initialization scripts are now supported with the envrionment variable HYSTARTUP.
  • The module hy.extra.reserved has a new function special.
  • New module hy.contrib.destructure for Clojure-style destructuring.
  • New module hy.contrib.slicing for multi-index sequence slicing.

Bug Fixes

  • Fixed the identifier J being incorrectly parsed as a complex number.
  • Attempts to assign to constants are now more reliably detected.
  • Fixed a bug where AST nodes from macro expansion did not properly receive source locations.
  • Fixed doc sometimes failing to find core macros.
  • doc now works with names that need mangling.
  • Fixed bugs with require of names that need mangling.
  • Fixed a compiler crash from trying to use .. as an operator.
  • Fixed namespace pollution caused by automatic imports of Hy builtins and macros.
  • require now works with relative imports and can name modules as members, as in (require [hy.contrib [walk]]).
  • Fixed error handling for illegal macro names.
  • Fixed hyc and hy2py not finding relative imports.
  • Fixed hy.contrib.walk.smacrolet requiring a module name.

Misc. Improvements

  • The library astor is no longer required on Pythons ≥ 3.9.

0.20.0

25 Jan 19:36
Compare
Choose a tag to compare

Removals

  • Python 3.5 is no longer supported.

New Features

  • let macro now supports extended iterable unpacking syntax.
  • New contrib module pprint, a Hy equivalent of python.pprint.

Bug Fixes

  • Fixed a bug that made hy.eval from Python fail on require.
  • Fixed a bug that prevented pickling of keyword objects.
  • Fixed a compiler crash from setv with an odd number of arguments in defclass.