From 4cdfdfbafec42ccb53a19114dd7c41fb66ecb1b3 Mon Sep 17 00:00:00 2001 From: gilch Date: Sun, 9 Aug 2015 01:09:52 -0600 Subject: [PATCH] remove defun in favor of defn --- docs/language/api.rst | 14 +++++++------- hy/contrib/botsbuildbots.hy | 2 +- hy/contrib/loop.hy | 2 +- hy/core/bootstrap.hy | 6 +++--- hy/core/macros.hy | 2 +- scripts/reformat-changelog | 12 ++++++------ tests/native_tests/native_macros.hy | 1 - 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/language/api.rst b/docs/language/api.rst index 45b1f68..05d122c 100644 --- a/docs/language/api.rst +++ b/docs/language/api.rst @@ -378,10 +378,10 @@ below: .. _defn: -defn / defun +defn ------------ -``defn`` and ``defun`` macros are used to define functions. They take three +``defn`` macro is used to define functions. It takes three parameters: the *name* of the function to define, a vector of *parameters*, and the *body* of the function: @@ -488,18 +488,18 @@ Parameters may have the following keywords in front of them: Availability: Python 3. -.. _defn-alias / defun-alias: +.. _defn-alias: -defn-alias / defun-alias +defn-alias ------------------------ .. versionadded:: 0.10.0 -The ``defn-alias`` and ``defun-alias`` macros are much like `defn`_, +The ``defn-alias`` and 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`` and -``defun-alias`` are no different from ``defn`` and ``defun``. +symbols for function names as the first parameter, ``defn-alias`` +is no different from ``defn``. .. code-block:: clj diff --git a/hy/contrib/botsbuildbots.hy b/hy/contrib/botsbuildbots.hy index 0063263..98f3737 100644 --- a/hy/contrib/botsbuildbots.hy +++ b/hy/contrib/botsbuildbots.hy @@ -18,7 +18,7 @@ ;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;; DEALINGS IN THE SOFTWARE. -(defun Botsbuildbots () (Botsbuildbots)) +(defn Botsbuildbots () (Botsbuildbots)) (defmacro Botsbuildbots [] "Build bots, repeatedly.^W^W^WPrint the AUTHORS, forever." diff --git a/hy/contrib/loop.hy b/hy/contrib/loop.hy index 2c2690a..17bb0d9 100644 --- a/hy/contrib/loop.hy +++ b/hy/contrib/loop.hy @@ -75,7 +75,7 @@ (defmacro/g! loop [bindings &rest body] ;; Use inside functions like so: - ;; (defun factorial [n] + ;; (defn factorial [n] ;; (loop [[i n] ;; [acc 1]] ;; (if (= i 0) diff --git a/hy/core/bootstrap.hy b/hy/core/bootstrap.hy index 741e354..f64c3d5 100644 --- a/hy/core/bootstrap.hy +++ b/hy/core/bootstrap.hy @@ -40,12 +40,12 @@ ret) -(defmacro-alias [defn defun] [name lambda-list &rest body] +(defmacro defn [name lambda-list &rest body] "define a function `name` with signature `lambda-list` and body `body`" (if (not (= (type name) HySymbol)) - (macro-error name "defn/defun takes a name as first argument")) + (macro-error name "defn takes a name as first argument")) (if (not (isinstance lambda-list HyList)) - (macro-error name "defn/defun takes a parameter list as second argument")) + (macro-error name "defn takes a parameter list as second argument")) `(setv ~name (fn ~lambda-list ~@body))) diff --git a/hy/core/macros.hy b/hy/core/macros.hy index 0cf2561..0ba0671 100644 --- a/hy/core/macros.hy +++ b/hy/core/macros.hy @@ -210,7 +210,7 @@ (sys.exit ~retval))))) -(defmacro-alias [defn-alias defun-alias] [names lambda-list &rest body] +(defmacro defn-alias [names lambda-list &rest body] "define one function with several names" (let [[main (first names)] [aliases (rest names)]] diff --git a/scripts/reformat-changelog b/scripts/reformat-changelog index 2c74480..cb4f2a0 100755 --- a/scripts/reformat-changelog +++ b/scripts/reformat-changelog @@ -7,13 +7,13 @@ (setv *maintainer-line* " -- Alexander Artemenko Thu, 30 Sep 2014 13:06:09 +0400") -(defun read-lines-from-file [filename] +(defn read-lines-from-file [filename] (let [[f (codecs.open filename "r" "utf-8")]] (fn [] (let [[line (.readline f) ]] line)))) -(defun get-version-number [line] +(defn get-version-number [line] (let [[match (re.search r"Changes from.*(\d+\.\d+\.\d+)$" line)]] (if match (let [[version (.group match (int 1))] @@ -26,7 +26,7 @@ (.join "." (map str numbered))))))) -(defun read-version-content [reader] +(defn read-version-content [reader] (setv line (reader)) (setv content []) (while (and line (not (get-version-number line))) @@ -35,12 +35,12 @@ [content line]) -(defun read-versions-from-file [filename] +(defn read-versions-from-file [filename] (let [[reader (read-lines-from-file filename)]] (read-versions-rec (reader) reader))) -(defun read-versions-rec [line reader] +(defn read-versions-rec [line reader] (if line (let [[version (get-version-number line)] [[content next-line] (read-version-content reader)]] @@ -50,7 +50,7 @@ (read-versions-rec next-line reader))) [])) -(defun format-deb-version [version] +(defn format-deb-version [version] (setv result [(.format "hy ({}) unstable; urgency=low" (get version "from"))]) (for [line (get version "content")] diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index a27e465..69b349c 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -227,7 +227,6 @@ (defn test-defn-alias [] (defn-alias [tda-main tda-a1 tda-a2] [] :bazinga) - (defun-alias [tda-main tda-a1 tda-a2] [] :bazinga) (assert (= (tda-main) :bazinga)) (assert (= (tda-a1) :bazinga)) (assert (= (tda-a2) :bazinga))