mirror of
https://github.com/kanaka/mal.git
synced 2024-08-16 17:20:23 +03:00
guile, scheme: fix fn? when metadata contains "ismacro"
Let `with-meta f m` create a function even if f is a macro, instead of setting an "ismacro" metadata that is never used again (and breaks self-hosting). Also move the test for fn? from Optional to Deferrable, the function is used for self-hosting.
This commit is contained in:
parent
313f01eff5
commit
5e5d4892b5
@ -150,7 +150,7 @@
|
||||
((callable? c)
|
||||
(let ((cc (make-callable ht
|
||||
(callable-unbox c)
|
||||
(and (hash-table? ht) (hash-ref ht "ismacro"))
|
||||
#f
|
||||
(callable-closure c))))
|
||||
cc))
|
||||
(else
|
||||
|
@ -275,7 +275,7 @@
|
||||
((func? x)
|
||||
(let ((func (make-func (func-ast x) (func-params x)
|
||||
(func-env x) (func-fn x))))
|
||||
(func-macro?-set! func (func-macro? x))
|
||||
(func-macro?-set! #f)
|
||||
(func-meta-set! func meta)
|
||||
func))
|
||||
(else
|
||||
|
@ -64,6 +64,19 @@
|
||||
(meta +)
|
||||
;=>nil
|
||||
|
||||
;; Testing fn? function
|
||||
(fn? +)
|
||||
;=>true
|
||||
(fn? (fn* () 0))
|
||||
;=>true
|
||||
(fn? cond)
|
||||
;=>false
|
||||
(fn? "+")
|
||||
;=>false
|
||||
(fn? :+)
|
||||
;=>false
|
||||
(fn? ^{"ismacro" true} (fn* () 0))
|
||||
;=>true
|
||||
|
||||
;;
|
||||
;; Make sure closures and metadata co-exist
|
||||
@ -139,18 +152,6 @@
|
||||
|
||||
(def! add1 (fn* (x) (+ x 1)))
|
||||
|
||||
;; Testing fn? function
|
||||
(fn? +)
|
||||
;=>true
|
||||
(fn? add1)
|
||||
;=>true
|
||||
(fn? cond)
|
||||
;=>false
|
||||
(fn? "+")
|
||||
;=>false
|
||||
(fn? :+)
|
||||
;=>false
|
||||
|
||||
;; Testing macro? function
|
||||
(macro? cond)
|
||||
;=>true
|
||||
|
Loading…
Reference in New Issue
Block a user