Browse code
feat(specializer): add Eql specializer
(defmethod foo ((a (eql "a"))) 1)
(foo "a") ;; => 1
Showing 1 changed files
... | ... |
@@ -230,6 +230,24 @@ Shape.prototype = Object.assign(new Specializer(), { |
230 | 230 |
}, |
231 | 231 |
}); |
232 | 232 |
|
233 |
+export function Eql(val) { |
|
234 |
+ if (!(this instanceof Eql)) { |
|
235 |
+ return new Eql(val); |
|
236 |
+ } |
|
237 |
+ this.val = val; |
|
238 |
+} |
|
239 |
+Eql.prototype = Object.assign(new Specializer(), { |
|
240 |
+ toString() { |
|
241 |
+ return `AEql(${this.val})`; |
|
242 |
+ }, |
|
243 |
+ matches(other) { |
|
244 |
+ return this.val === other; |
|
245 |
+ }, |
|
246 |
+ super_of(other) { |
|
247 |
+ return false; |
|
248 |
+ }, |
|
249 |
+}); |
|
250 |
+ |
|
233 | 251 |
// function trace(fun) { |
234 | 252 |
// return function (...args) { |
235 | 253 |
// console.log(fun, `args are: thsds`, this, 'others', args); |