(type-of (lambda (a) (print a))) ; -> 1. Expected 16
FrankC01 opened this issue · 5 comments
Not recognizing a function vs. a list
This breaks (fnc? ...)
Yes I can see the issue. Fnc? Is just checking if the object is an instance of a built in function or complied function as it where ! And a Lisp Lambda is really just a list !
Is there any plan to either implement some support for type information? Registering type tester's would be a nice advantage to things like (env? _)
, (props? _)
, (hmap? _)
, etc.
It would seem a TYPE_SERVICE hierarchy could be genned at run-time or JIT time. We could also spit it out in a compilation pass and doctor it up for loading. The Service could provide the tree maintenance and persist to extend at run time with a write back file store?
Agreed we need a shake up on the type info stuff !
In the mean time I propose we add these 2 calls to boot.inc.
(defun-bind fun? (_)
(and (lst? _) (> (length _) 0) (eql (elem 0 _) 'lambda)))
(defun-bind macro? (_)
(and (lst? _) (> (length _) 0) (eql (elem 0 _) 'macro)))
To enable us to things like this.
(defun-bind boot-fncs ()
(defq out (list) e (penv))
(while (penv e) (setq e (penv e)))
(each (lambda ((k v))
(if (fnc? v) (push out k))) (tolist e))
(sort cmp out))
(defun-bind boot-funs ()
(defq out (list) e (penv))
(while (penv e) (setq e (penv e)))
(each (lambda ((k v))
(if (fun? v) (push out k))) (tolist e))
(sort cmp out))
(defun-bind boot-macros ()
(defq out (list) e (penv))
(while (penv e) (setq e (penv e)))
(each (lambda ((k v))
(if (macro? v) (push out k))) (tolist e))
(sort cmp out))
pushed these additions.