mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 13:55:55 +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)
|
((callable? c)
|
||||||
(let ((cc (make-callable ht
|
(let ((cc (make-callable ht
|
||||||
(callable-unbox c)
|
(callable-unbox c)
|
||||||
(and (hash-table? ht) (hash-ref ht "ismacro"))
|
#f
|
||||||
(callable-closure c))))
|
(callable-closure c))))
|
||||||
cc))
|
cc))
|
||||||
(else
|
(else
|
||||||
|
@ -275,7 +275,7 @@
|
|||||||
((func? x)
|
((func? x)
|
||||||
(let ((func (make-func (func-ast x) (func-params x)
|
(let ((func (make-func (func-ast x) (func-params x)
|
||||||
(func-env x) (func-fn x))))
|
(func-env x) (func-fn x))))
|
||||||
(func-macro?-set! func (func-macro? x))
|
(func-macro?-set! #f)
|
||||||
(func-meta-set! func meta)
|
(func-meta-set! func meta)
|
||||||
func))
|
func))
|
||||||
(else
|
(else
|
||||||
|
@ -64,6 +64,19 @@
|
|||||||
(meta +)
|
(meta +)
|
||||||
;=>nil
|
;=>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
|
;; Make sure closures and metadata co-exist
|
||||||
@ -139,18 +152,6 @@
|
|||||||
|
|
||||||
(def! add1 (fn* (x) (+ x 1)))
|
(def! add1 (fn* (x) (+ x 1)))
|
||||||
|
|
||||||
;; Testing fn? function
|
|
||||||
(fn? +)
|
|
||||||
;=>true
|
|
||||||
(fn? add1)
|
|
||||||
;=>true
|
|
||||||
(fn? cond)
|
|
||||||
;=>false
|
|
||||||
(fn? "+")
|
|
||||||
;=>false
|
|
||||||
(fn? :+)
|
|
||||||
;=>false
|
|
||||||
|
|
||||||
;; Testing macro? function
|
;; Testing macro? function
|
||||||
(macro? cond)
|
(macro? cond)
|
||||||
;=>true
|
;=>true
|
||||||
|
Loading…
Reference in New Issue
Block a user