Skip to content

Commit

Permalink
Removed the meth macro.
Browse files Browse the repository at this point in the history
`meth` forms are most useful in `deftile`, and we're no longer actually using the macro there.
  • Loading branch information
Kodiologist committed Jan 9, 2024
1 parent 85a6dfc commit 560be8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
10 changes: 5 additions & 5 deletions simalq/geometry.hy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(require
hyrule [unless do-n]
simalq.macros [defdataclass defmeth meth])
simalq.macros [defdataclass defmeth])
(import
itertools [chain]
toolz [unique]
Expand Down Expand Up @@ -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 [
"" "" "" ""
Expand All @@ -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 []
Expand Down
5 changes: 0 additions & 5 deletions simalq/macros.hy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions simalq/tile/unimplemented.hy
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
(require
simalq.macros [meth])
(import
dataclasses [dataclass]
simalq.tile [Tile])
Expand Down Expand Up @@ -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)))))))
Expand Down

0 comments on commit 560be8f

Please sign in to comment.