Generalize forms to report full metadata
Closed this issue · 4 comments
JerroldJacobsen commented
ORIGINAL SUGGESTION
the proposed command would return a data structure like:
nth F 2 (n l) Find the nth value of a list, starting from zero
len N 1 (l) Return the length of a list
butlast F 1 (x) Return everything but the last element
drop F 2 (n l) Drop n items from a list, then return the rest
or like
{:form "nth" :type "F" :arity "2" :args "(n l)" :def "Find the nth value of a list, starting from zero"}
CHECKLIST
- convert function arguments from strings to lists
- convert doc forms, where strings, to lists
- make
forms
report all available metadata inassociation-list-likelist format - fuzz-test the result prior to merging into master
eigenhombre commented
Maybe best to just extend forms
to include all the metadata. It's a breaking change but still very early days.
eigenhombre commented
Currently the fields of interest are mostly implemented in Go as strings, which is not ideal for this use case due to the difficulty converting them back into L1 lists. So these fields should be refactored to make them more amenable to representation as Lisp data.
eigenhombre commented
Seems to be working on branch:
(len (forms))
;;=>
135
(map len (forms))
;;=>
(5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5)
(first (forms))
;;=>
(*
native-function
0
t
((Multiply 0 or more numbers)))
(defn extract-example-from-doc (doc)
(cond ((not doc) ())
((= (caar doc) 'examples) doc)
(t (extract-example-from-doc (cdr doc)))))
(defn extract-example (form)
(extract-example-from-doc (cdaddddr form)))
(remove not (take 3 (map extract-example (forms))))
;;=>
(((examples (** 1 0) (** 2 4) (** 10 10))))
Will review, merge and release.
eigenhombre commented
Code will probably will still need a little smoothing out over time, but this seems workable for now.