Page 1 of 1

Function documentation via REPL

Posted: Mon Oct 22, 2012 7:52 am
by jopython
Is it possible to see the documentation for a builtin function (within MAIN context) via the REPL?

Re: Function documentation via REPL

Posted: Mon Oct 22, 2012 8:25 am
by cormullion
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, here's the first one I found. There are others, but search isn't phpbb's strong point... :)

Re: Function documentation via REPL

Posted: Tue Oct 23, 2012 8:53 am
by johu
May I introduce my scripts command-help.lsp?

'primitives' will display the names of primitive functions.

Code: Select all

> (primitives "ap")
(append append-file apply)
> (primitives "file")
(file-info file?)
It can use the regular expression by adding flag.

Code: Select all

> (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.

Code: Select all

> (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 command-event,

Code: Select all

> 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:

Code: Select all

> 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,

Re: Function documentation via REPL

Posted: Tue Oct 23, 2012 2:58 pm
by jopython
Thank you everyone for all the answers provided.
I tried searching before i asked this question.

Re: Function documentation via REPL

Posted: Tue Oct 23, 2012 7:08 pm
by cormullion
It's hard to find things on this forum sometimes...

Re: Function documentation via REPL

Posted: Wed Oct 24, 2012 2:19 pm
by Ryon
phpBB's search function has a lot of room for improvement! Anybody want to wrestle with their code? https://www.phpbb.com/get-involved/

Or, try this instead: At the Google search line, enter
or enter whatever other search term you want.