Update docs and NEWS for HyCons removal
This commit is contained in:
parent
c93a60ede0
commit
bbf669d407
6
NEWS.rst
6
NEWS.rst
@ -3,6 +3,12 @@
|
|||||||
Unreleased
|
Unreleased
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
Removals
|
||||||
|
------------------------------
|
||||||
|
* Dotted lists, `HyCons`, `cons`, `cons?`, and `list*` have been removed.
|
||||||
|
These were redundant with Python's built-in data structures and Hy's most
|
||||||
|
common model types (`HyExpression`, `HyList`, etc.).
|
||||||
|
|
||||||
Other Breaking Changes
|
Other Breaking Changes
|
||||||
------------------------------
|
------------------------------
|
||||||
* Mangling rules have been overhauled, such that mangled names
|
* Mangling rules have been overhauled, such that mangled names
|
||||||
|
@ -98,49 +98,6 @@ inverted. So, ``((complement f) x)`` is equivalent to ``(not (f x))``.
|
|||||||
True
|
True
|
||||||
|
|
||||||
|
|
||||||
cons
|
|
||||||
----
|
|
||||||
|
|
||||||
.. versionadded:: 0.10.0
|
|
||||||
|
|
||||||
Usage: ``(cons a b)``
|
|
||||||
|
|
||||||
Returns a fresh :ref:`cons cell <hycons>` with car *a* and cdr *b*.
|
|
||||||
|
|
||||||
.. code-block:: hy
|
|
||||||
|
|
||||||
=> (setv a (cons 'hd 'tl))
|
|
||||||
|
|
||||||
=> (= 'hd (get a 0))
|
|
||||||
True
|
|
||||||
|
|
||||||
=> (= 'tl (cut a 1))
|
|
||||||
True
|
|
||||||
|
|
||||||
|
|
||||||
cons?
|
|
||||||
-----
|
|
||||||
|
|
||||||
.. versionadded:: 0.10.0
|
|
||||||
|
|
||||||
Usage: ``(cons? foo)``
|
|
||||||
|
|
||||||
Checks whether *foo* is a :ref:`cons cell <hycons>`.
|
|
||||||
|
|
||||||
.. code-block:: hy
|
|
||||||
|
|
||||||
=> (setv a (cons 'hd 'tl))
|
|
||||||
|
|
||||||
=> (cons? a)
|
|
||||||
True
|
|
||||||
|
|
||||||
=> (cons? None)
|
|
||||||
False
|
|
||||||
|
|
||||||
=> (cons? [1 2 3])
|
|
||||||
False
|
|
||||||
|
|
||||||
|
|
||||||
.. _constantly:
|
.. _constantly:
|
||||||
|
|
||||||
constantly
|
constantly
|
||||||
@ -606,41 +563,6 @@ Check whether *foo* is a :ref:`keyword<HyKeyword>`.
|
|||||||
=> (keyword? foo)
|
=> (keyword? foo)
|
||||||
False
|
False
|
||||||
|
|
||||||
.. _list*-fn:
|
|
||||||
|
|
||||||
list*
|
|
||||||
-----
|
|
||||||
|
|
||||||
Usage: ``(list* head &rest tail)``
|
|
||||||
|
|
||||||
Generates a chain of nested cons cells (a dotted list) containing the
|
|
||||||
arguments. If the argument list only has one element, return it.
|
|
||||||
|
|
||||||
.. code-block:: hy
|
|
||||||
|
|
||||||
=> (list* 1 2 3 4)
|
|
||||||
<HyCons (
|
|
||||||
HyInteger(1)
|
|
||||||
HyInteger(2)
|
|
||||||
HyInteger(3)
|
|
||||||
. HyInteger(4))>
|
|
||||||
=> (list* 1 2 3 [4])
|
|
||||||
[HyInteger(1), HyInteger(2), HyInteger(3), 4]
|
|
||||||
=> (list* 1)
|
|
||||||
1
|
|
||||||
=> (cons? (list* 1 2 3 4))
|
|
||||||
True
|
|
||||||
=> (list* 1 10 2 20 '{})
|
|
||||||
HyDict([
|
|
||||||
HyInteger(1), HyInteger(10),
|
|
||||||
HyInteger(2), HyInteger(20)])
|
|
||||||
=> (list* 1 10 2 20 {})
|
|
||||||
<HyCons (
|
|
||||||
HyInteger(1)
|
|
||||||
HyInteger(10)
|
|
||||||
HyInteger(2)
|
|
||||||
HyInteger(20)
|
|
||||||
. HyDict())>
|
|
||||||
|
|
||||||
.. _macroexpand-fn:
|
.. _macroexpand-fn:
|
||||||
|
|
||||||
|
@ -168,39 +168,6 @@ HyKeyword
|
|||||||
``hy.models.HyKeyword`` represents keywords in Hy. Keywords are
|
``hy.models.HyKeyword`` represents keywords in Hy. Keywords are
|
||||||
symbols starting with a ``:``. See :ref:`syntax-keywords`.
|
symbols starting with a ``:``. See :ref:`syntax-keywords`.
|
||||||
|
|
||||||
.. _hycons:
|
|
||||||
|
|
||||||
Cons Cells
|
|
||||||
==========
|
|
||||||
|
|
||||||
``hy.models.HyCons`` is a representation of Python-friendly `cons
|
|
||||||
cells`_. Cons cells are especially useful to mimic features of "usual"
|
|
||||||
LISP variants such as Scheme or Common Lisp.
|
|
||||||
|
|
||||||
.. _cons cells: https://en.wikipedia.org/wiki/Cons
|
|
||||||
|
|
||||||
A cons cell is a 2-item object, containing a ``car`` (head) and a
|
|
||||||
``cdr`` (tail). In some Lisp variants, the cons cell is the fundamental
|
|
||||||
building block, and S-expressions are actually represented as linked
|
|
||||||
lists of cons cells. This is not the case in Hy, as the usual
|
|
||||||
expressions are made of Python lists wrapped in a
|
|
||||||
``HyExpression``. However, the ``HyCons`` mimics the behavior of
|
|
||||||
"usual" Lisp variants thusly:
|
|
||||||
|
|
||||||
- ``(cons something None)`` is ``(HyExpression [something])``
|
|
||||||
- ``(cons something some-list)`` is ``((type some-list) (+ [something]
|
|
||||||
some-list))`` (if ``some-list`` inherits from ``list``).
|
|
||||||
- ``(get (cons a b) 0)`` is ``a``
|
|
||||||
- ``(cut (cons a b) 1)`` is ``b``
|
|
||||||
|
|
||||||
Hy supports a dotted-list syntax, where ``'(a . b)`` means ``(cons 'a
|
|
||||||
'b)`` and ``'(a b . c)`` means ``(cons 'a (cons 'b 'c))``. If the
|
|
||||||
compiler encounters a cons cell at the top level, it raises a
|
|
||||||
compilation error.
|
|
||||||
|
|
||||||
``HyCons`` wraps the passed arguments (car and cdr) in Hy types, to ease
|
|
||||||
the manipulation of cons cells in a macro context.
|
|
||||||
|
|
||||||
Hy Internal Theory
|
Hy Internal Theory
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user