Function documentation via REPL

Q&A's, tips, howto's
Post Reply
jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Function documentation via REPL

Post by jopython »

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

cormullion
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Function documentation via REPL

Post 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... :)

johu
Posts: 143
Joined: Mon Feb 08, 2010 8:47 am

Re: Function documentation via REPL

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

jopython
Posts: 123
Joined: Tue Sep 14, 2010 3:08 pm

Re: Function documentation via REPL

Post by jopython »

Thank you everyone for all the answers provided.
I tried searching before i asked this question.

cormullion
Posts: 2037
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: Function documentation via REPL

Post by cormullion »

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

Ryon
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Re: Function documentation via REPL

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

Post Reply