diff --git a/docs/contrib/alias.rst b/docs/contrib/alias.rst deleted file mode 100644 index eb610cf..0000000 --- a/docs/contrib/alias.rst +++ /dev/null @@ -1,60 +0,0 @@ -============ -Alias macros -============ - -.. versionadded:: 0.12 - -The alias macro module provides the ``(defn-alias)`` and -``(defmacro-alias)``, that were in Hy core previously. - - -Macros -====== - - -.. _defn-alias: - -defn-alias ------------------------- - -The ``defn-alias`` macro is much like ``defn``, -with the distinction that instead of defining a function with a single -name, these can also define aliases. Other than taking a list of -symbols for function names as the first parameter, ``defn-alias`` -is no different from ``defn``. - -.. code-block:: clj - - => (defn-alias [main-name alias] [] - ... (print "Hello!")) - => (main-name) - "Hello!" - => (alias) - "Hello!" - - -.. _defmacro-alias: - -defmacro-alias --------------- - -``defmacro-alias`` is used to define macros with multiple names -(aliases). The general format is ``(defmacro-alias [names] [parameters] -expr)``. It creates multiple macros with the same parameter list and -body, under the specified list of names. - -The following example defines two macros, both of which allow the user -to write code in infix notation. - -.. code-block:: clj - - => (defmacro-alias [infix infi] [code] - ... (quasiquote ( - ... (unquote (get code 1)) - ... (unquote (get code 0)) - ... (unquote (get code 2))))) - - => (infix (1 + 1)) - 2 - => (infi (1 + 1)) - 2 diff --git a/docs/contrib/index.rst b/docs/contrib/index.rst index cb881c5..f9f2d92 100644 --- a/docs/contrib/index.rst +++ b/docs/contrib/index.rst @@ -7,7 +7,6 @@ Contents: .. toctree:: :maxdepth: 3 - alias anaphoric flow loop diff --git a/hy/contrib/alias.hy b/hy/contrib/alias.hy deleted file mode 100644 index 56c4a7c..0000000 --- a/hy/contrib/alias.hy +++ /dev/null @@ -1,39 +0,0 @@ -;; Copyright (c) 2014, 2015 Gergely Nagy -;; Copyright (c) 2014, 2015 Paul Tagliamonte - -;; Permission is hereby granted, free of charge, to any person obtaining a -;; copy of this software and associated documentation files (the "Software"), -;; to deal in the Software without restriction, including without limitation -;; the rights to use, copy, modify, merge, publish, distribute, sublicense, -;; and/or sell copies of the Software, and to permit persons to whom the -;; Software is furnished to do so, subject to the following conditions: - -;; The above copyright notice and this permission notice shall be included in -;; all copies or substantial portions of the Software. - -;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -;; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -;; DEALINGS IN THE SOFTWARE. - -(defmacro defmacro-alias [names lambda-list &rest body] - "define one macro with several names" - (setv ret `(do)) - (for* [name names] - (.append ret - `(defmacro ~name ~lambda-list ~@body))) - ret) - - -(defmacro defn-alias [names lambda-list &rest body] - "define one function with several names" - (let [main (first names) - aliases (rest names)] - (setv ret `(do (defn ~main ~lambda-list ~@body))) - (for* [name aliases] - (.append ret - `(setv ~name ~main))) - ret)) diff --git a/tests/native_tests/contrib/alias.hy b/tests/native_tests/contrib/alias.hy deleted file mode 100644 index a88cb93..0000000 --- a/tests/native_tests/contrib/alias.hy +++ /dev/null @@ -1,8 +0,0 @@ -(require [hy.contrib.alias [defn-alias]]) - -(defn test-defn-alias [] - (defn-alias [tda-main tda-a1 tda-a2] [] :bazinga) - (assert (= (tda-main) :bazinga)) - (assert (= (tda-a1) :bazinga)) - (assert (= (tda-a2) :bazinga)) - (assert (= tda-main tda-a1 tda-a2)))