Code: Select all
(define-macro (def)
"Creates a lambda expression, while checking for doc-strings"
(let ((__def_func (args))
(__def_help ""))
(dolist (val (rest (__def_func 0)))
(if (string? val)
(set '__def_help (append __def_help val)))
(if (symbol? val)
(set '__def_help (append __def_help "\n " (string val) "\t - "))))
(nth-set (__def_func 0) (clean string? (__def_func 0)))
(set '__def_help (append (string (nth 0 __def_func)) "\n" __def_help))
(if (string? (nth 1 __def_func))
(begin
(set '__def_help (append __def_help "\n" (nth 1 __def_func)))
(pop __def_func 1)))
(push __def_help __def_func 1)
(push 'define __def_func)
(eval __def_func)
)
)
(def (help "get quick help on function"
on-func "function you want help for")
{displays the doc-string of a function
if on-func is a string, it searches all symbols for occurrence of this string
if on-func is nil, return a list of all lambda, macro-lambda and primitives}
(if
(nil? on-func)
(filter (lambda (x) (or (lambda? (eval x))(macro? (eval x))(primitive? (eval x)))) (symbols))
(string? on-func)
(filter (lambda (x) (find on-func (string x))) (symbols))
(lambda? on-func)
(if (string? (nth 1 on-func))
(begin
(println (nth 1 on-func))
'-)
'not-documented)
'not-a-lambda-expression
)
)
def - see 'help definition
help -
Code: Select all
> (help help)
(help on-func)
get quick help on function
on-func - function you want help for
displays the doc-string of a function
if on-func is a string, it searches all symbols for occurrence of this string
if on-func is nil, return a list of all lambda, macro-lambda and primitives
-
> (help "xml")
(xml-error xml-parse xml-type-tags)
Ingo