From 560be8fe4bd4e166253fc89b789c60cedccfca7f Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 21 Dec 2023 16:51:34 -0500 Subject: [PATCH] Removed the `meth` macro. `meth` forms are most useful in `deftile`, and we're no longer actually using the macro there. --- simalq/geometry.hy | 10 +++++----- simalq/macros.hy | 5 ----- simalq/tile/unimplemented.hy | 8 +++----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/simalq/geometry.hy b/simalq/geometry.hy index 64a600a..8229297 100644 --- a/simalq/geometry.hy +++ b/simalq/geometry.hy @@ -1,6 +1,6 @@ (require hyrule [unless do-n] - simalq.macros [defdataclass defmeth meth]) + simalq.macros [defdataclass defmeth]) (import itertools [chain] toolz [unique] @@ -53,10 +53,10 @@ (setv Direction.all #( Direction.N Direction.NE Direction.E Direction.SE Direction.S Direction.SW Direction.W Direction.NW)) - (setv Direction.abbr (property (meth [] + (setv Direction.abbr (property (fn [self] (next (gfor [k v] (.items (vars Direction)) - :if (is v @) + :if (is v self) k))))) (setv arrows [ "↑" "↗" "→" "↘" @@ -71,8 +71,8 @@ d2 Direction.all :if (and (= d1.x (- d2.x)) (= d1.y (- d2.y))) d1 d2)) - (setv Direction.opposite (property (meth [] - (get opposites @)))))) + (setv Direction.opposite (property (fn [self] + (get opposites self)))))) (defdataclass Pos [] diff --git a/simalq/macros.hy b/simalq/macros.hy index ef6c4ce..2b4c3cf 100644 --- a/simalq/macros.hy +++ b/simalq/macros.hy @@ -62,11 +62,6 @@ (setv decorators [] [fname params #* body] args)) (_defmeth decorators fname params body)) -(defmacro meth [params #* body] - "As `defmeth`, for an anonymous function." - (setv fname (hy.gensym "meth")) - (+ (_defmeth [] fname params body) `(~fname))) - (defn _defmeth [decorators fname params body] (defn f [x] (cond diff --git a/simalq/tile/unimplemented.hy b/simalq/tile/unimplemented.hy index f883b37..415cb89 100644 --- a/simalq/tile/unimplemented.hy +++ b/simalq/tile/unimplemented.hy @@ -1,5 +1,3 @@ -(require - simalq.macros [meth]) (import dataclasses [dataclass] simalq.tile [Tile]) @@ -95,9 +93,9 @@ #(UnimplementedTile) (dict :fields ["tile_extras"] - :__init__ (meth [* pos [tile-extras None]] - (object.__setattr__ @ "pos" pos) - (object.__setattr__ @ "tile_extras" tile-extras)) + :__init__ (fn [self * pos [tile-extras None]] + (object.__setattr__ self "pos" pos) + (object.__setattr__ self "tile_extras" tile-extras)) :stem stem :read-tile-extras (classmethod (fn [cls mk-pos a b] (dict :tile-extras #(a b)))))))