Function documentation via REPL

Started by jopython, October 22, 2012, 12:52:27 AM

Previous topic - Next topic

jopython

Is it possible to see the documentation for a builtin function (within MAIN context) via the REPL?

cormullion

#1
By referring to the documentation, yes (not by crawling inside the executable :). This is a frequently-asked question, and you'll find many posts in this forum. For example, http://newlispfanclub.alh.net/forum/viewtopic.php?f=15&t=3956">here's the first one I found. There are others, but search isn't phpbb's strong point... :)

johu

#2
May I introduce my scripts http://johu02.wordpress.com/command-help-lsp/">command-help.lsp?



'primitives' will display the names of primitive functions.

> (primitives "ap")
(append append-file apply)
> (primitives "file")
(file-info file?)

It can use the regular expression by adding flag.

> (primitives {file$} true)
(append-file copy-file delete-file read-file rename-file write-file)
> (primitives {?$} true)
(NaN? array? atom? context? directory? empty? even? file? float? global? inf? integer?
 lambda? legal? list? macro? nil? null? number? odd? primitive? protected? quote?
 string? symbol? true? zero?)

And 'syntax' will display the syntax of a primitive function.

> (syntax 'struct)
struct
syntax: (struct symbol [str-data-type ... ])
""
> (syntax 'command-event true)
command-event
syntax: (command-event sym-event-handler | func-event-handler)
Specifies a user defined function for pre-processing the newLISP command-line
before it gets evaluated. This can be used to write customized interactive
 newLISP shells and to transform HTTP requests when running in server mode.
""

Option flag is used for adding notes.



Addionally, if using http://www.newlisp.org/downloads/newlisp_manual.html#command-event">command-event,

> replace
replace !
syntax: (replace exp-key list exp-replacement [func-compare])
syntax: (replace exp list)
syntax: (replace str-key str-data exp-replacement)
syntax: (replace str-pattern str-data exp-replacement int-regex-option)
>

Option flag is available by following:

> char
char utf8
syntax: (char str [int-index [true]])
syntax: (char int)
> (syntax:set-flag true)
true
> char
char utf8
syntax: (char str [int-index [true]])
syntax: (char int)
Given a string argument, extracts the character at int-index from str,
returning either the ASCII value of that character or the Unicode value on UTF-8
 enabled
versions of newLISP.
>

This script uses "newlisp_manual.html" in the environment variable NEWLISPDIR.



Thanks,

jopython

#3
Thank you everyone for all the answers provided.

I tried searching before i asked this question.

cormullion

#4
It's hard to find things on this forum sometimes...

Ryon

#5
phpBB's search function has a lot of room for improvement! Anybody want to wrestle with their code? https://www.phpbb.com/get-involved/">https://www.phpbb.com/get-involved/



Or, try this instead: At the Google search line, enter
Quote
search site:http://newlispfanclub.alh.net/forum/">http://newlispfanclub.alh.net/forum/

or enter whatever other search term you want.
\"Give me a Kaypro 64 and a dial tone, and I can do anything!\"