Skip to content

Commit b63f271

Browse files
committed
undo some refactors
1 parent 69f66cc commit b63f271

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

src/rewrites.lisp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Example patterns:
4444
(assert (symbolp (car tree)) () "Functions must be constants in current impl")
4545
`(application ,(car tree) ,@(mapcar #'compile-tree (cdr tree))))
4646
(t ; equivalent to (atom tree)
47-
(and (symbolp tree)
48-
(string= "_" tree)
49-
(warn "Tried to compile a pattern involving a symbol named \"_\" in a package other than CLUCK. This will not be treated as a wildcard!"))
47+
(when (and (symbolp tree)
48+
(string= "_" tree))
49+
(warn "Tried to compile a pattern involving a symbol named \"_\" in a package other than CLUCK. This will not be treated as a wildcard!"))
5050
`(constant ,tree)))))
5151
(make-instance 'naive-pattern :compiled-tree (compile-tree pattern)
5252
:num-vars (length return-vars))))
@@ -117,13 +117,15 @@ Example patterns:
117117
:test car=-fn))))))
118118

119119
(defun default-car-match-fn (a b)
120-
(unless (eql a b)
121-
'no-match))
120+
(if (eql a b)
121+
nil
122+
'no-match))
122123

123124
(defun default-merge-car-bound-values-fn (a b id)
124125
(declare (ignore id))
125-
(when (eql a b)
126-
(values a t)))
126+
(if (eql a b)
127+
(values a t)
128+
nil))
127129

128130
(defclass graph-pattern (pattern)
129131
((binding-restrictions

src/utils.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
(defun hash-table-peek (ht)
1010
(with-hash-table-iterator (next ht)
1111
(multiple-value-bind (has-value-p k) (next)
12-
(when has-value-p
13-
(values k t)))))
12+
(if has-value-p
13+
(values k t)
14+
(values nil nil)))))
1415

1516
(declftype (hash-table) t hash-table-pop)
1617
(defun hash-table-pop (ht)

tests/pattern-matching.lisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,9 @@
196196
"Allows bindings of the form (:exact sym) or (:bind sym). The former requires EQL between sym and the actual car and returns no bindings. The latter binds the car to the given symbol and never fails to match."
197197
(ecase (car binding-car)
198198
(:exact
199-
(unless (eql (second binding-car) actual-car)
200-
'no-match))
199+
(if (eql (second binding-car) actual-car)
200+
nil
201+
'no-match))
201202
(:bind
202203
`((,(second binding-car) . ,actual-car))))))
203204
(with-e-graph eg

0 commit comments

Comments
 (0)