The following functions are classless. They work generally on lists or symbolic atoms, which in wwlisp are not objects instantiated from classes. Classless functions can be of type subr, fsubr, expr, fexpr or macro. In wwlisp, the arguments of some functions are placed differently than in other lisps and dialects, because the first argument of any function determines the class of the function, and if this argument is classless (ie evaluates to a symbolic atom or a list), then a classless function will be called instead of a method of the class of the argument. |
Function Type | macro |
Arguments | a symbolic atom |
Return Value | an integer or a float |
Description | increments by one the value of the symbolic atom given as argument; returns the value |
Example | (setq counter 0) (++ counter) => 1 |
Function Type | macro |
Arguments | a symbolic atom |
Return Value | an integer or a float |
Description | decrements by one the value of the symbolic atom given as argument; the atom must prealably be initialized with an integer or a float; returns the new value |
Example | (setq counter 0) (-- counter) => -1 |
Function Type | subr |
Arguments | anything, anything |
Return Value | t or nil |
Description | returns t if the two arguments are totally similar but not necessarily at the same address in memory |
Example | (= 1 1) => t |
Function Type | subr |
Arguments | one, any type |
Return Value | returns an unsigned integer address |
Description | for integers, unsigned integers and floats, gives the address of the lowest byte of the item, for strings and binaries gives the address of the pointed block where it is allocated i.e. most frequently respectively on the string space or the binary space, and for atoms, lists and instantiated objects, gives the address of the lisp cell itself |
Example | (addressof "hello" ) : 0x424e6b33 (being the address of the string in string space, and which will change at each garbage collection) |
Function Type | fsubr |
Arguments | any s-expr in unlimited number |
Return Value | returns the value of the last argument or nil |
Description | evaluates all the arguments sequentially stopping at the first which value is nil; if the function reaches the end of the argument list, it returns the value of that last argument |
Example | (and (member 'a '(a b c d)) (> pi 3)) => t |
Function Type | subr |
Arguments | lists in unlimited number |
Return Value | a list or nil |
Description | returns a list made of duplicates of the concatenated argument list, the last argument being simply pointed to and not duplicated |
Example | (append '(a b c d) '(x y z)) => (a b c d x y z) |
Function Type | subr |
Arguments | a function name or lambda definition, a list |
Return Value | any value |
Description | applies the function to the list of arguments and returns its value |
Example | (apply '+ '(1 2 3)) => 6 |
Function Type | subr |
Arguments | anything |
Return Value | returns t or nil |
Description | returns t if the argument evaluates as an atom (either empty list, symbol, numeric, string, binary or instantiated object); nil otherwise |
Example | (atom stdin) => t |
Function Type | subr |
Arguments | optional t or nil, optional integer |
Return Value | list |
Description | if the first argument is nil returns the list of the names of the functions on the stack from invocation point; if the first argument is t, returns the list of the complete forms actives on the stack from invocation point; the second argument determines the maximal length of the list, 0 meaning unlimited length; this function is used in a nicer way by the debug functions :bt1 :bt2 :bt3 (see (help)) |
Example | (backtrace t) => ((backtrace t)) |
Function Type | subr |
Arguments | integer, integer |
Return Value | nil |
Description | emits a sound at frequency given by arg1 and duration in milliseconds given by arg2; in UNIX just gives always the terminal bell |
Example | (beep 437 1000) |
Function Type | subr |
Arguments | one, any type |
Return Value | t or nil |
Description | returns t if the argument is of the class binary directly or by inheritance (ie: is a subclass of) |
Example | (binaryp (make-instance binary 4)) => t |
Function Type | subr |
Arguments | a list of integers |
Return Value | a binary block |
Description | returns a binary block made of as much bytes as integers contained in the argument list; each byte is modulo 256 of the corresponding integer |
Example | (binchr '(0 0 0 0)) |
Function Type | subr |
Arguments | symbolic atom |
Return Value | t or nil |
Description | returns t if the symbolic atom given as argument has at least one non-nil property in the current dynamic environment; returns nil otherwise |
Example | (boundp 'car) => t |
Function Type | subr |
Arguments | optional integer |
Return Value | nil |
Description | sets a flag in the thread of which the id is given as argument, so that the evaluation loop stops and goes in debug mode as soon as possible; this has the same effect on any thread as doing control-c on the terminal has only on the main thread; if the argument is not supplied, the main thread will be interrupted |
Example | (break) |
Function Type | fexpr |
Arguments | a symbolic atom |
Return Value | nil |
Description | pretty-prints on stdout the definition of the function given as argument; prints as well interpreted library functions as user functions |
Example | (browse edit) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a backtrace of the call history stack, showing the names of the called functions |
Example | (bt1) |
Function Type | expr |
Arguments | none |
Return Value | nil |
Description | returns a backtrace of the call history stack, showing the detail of the called forms |
Example | (bt2) |
Function Type | expr |
Arguments | none |
Return Value | nil |
Description | returns a reversed backtrace of the call history stack, showing the detail of the called forms |
Example | (bt3) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car(car(car s-expr)))) |
Example | (caaaar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car(car(cdr s-expr)))) |
Example | (caaadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car(car s-expr))) |
Example | (caaar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car(cdr(car s-expr)))) |
Example | (caadar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car(cdr(car s-expr)))) |
Example | (caaddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car(cdr s-expr))) |
Example | (caadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(car s-expr)) |
Example | (caar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr(car(car s-expr)))) |
Example | (cadaar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr(car(cdr s-expr)))) |
Example | (cadadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr(car s-expr))) |
Example | (cadar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr(cdr(car s-expr)))) |
Example | (caddar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr(cdr(cdr s-expr)))) |
Example | (cadddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr(cdr s-expr))) |
Example | (caddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns (car(cdr s-expr)) |
Example | (cadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the first element of the list given as argument; nil is the list is empty |
Example | (car s-expr) |
Function Type | subr |
Arguments | anything |
Return Value | an unsigned integer |
Description | returns the content of the 'car' pointer of the cell given as argument |
Example | (carvalue 256) => 0x100 |
Function Type | fsubr |
Arguments | at least one symbol, then any number of s-expr |
Return Value | anything |
Description | evaluates the first argument and keeps it as a label for execution of a throw non-local jump; then evaluates sequentially each following s-expr; if somewhere in the sequence a throw is executed with the label stored by the catch , then an unwinding of the stack is done up to the catch , which return as value the value given as second argument to the throw ; catch can also recover the control when an interpreter error is thrown by using a label equal to the error index, or 'any-condition to catch any error |
Example | (catch 'lab1 (throw 'lab1 "hi" )) => "hi" (catch 'function-undefined (undefinedfunc)) => nil ; without the catch, (undefinedfunc) would have invoked the debugger |
Function Type | macro |
Arguments | list of labels, any number of s-expr |
Return Value | anything |
Description | generates a nested sequence of catch each with a label from the list given as first argument; then evaluates sequentially each following s-expr; if somewhere in the sequence a throw is executed with the label stored by the catch , then an unwinding of the stack is done up to the catch , which return as value the value given as second argument to the throw ; catch+ can also recover the control when an interpreter error is thrown by using a label which is an error index, or 'any-condition to catch any error |
Example | (catch+ (function-undefined function-invalid) (33)) => nil |
Function Type | subr |
Arguments | none |
Return Value | a list |
Description | returns a list of the catch labels pending, allowing to decide by advance if a throw will succeed |
Example | (catchlist) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car(car(car s-expr)))) |
Example | (cdaaar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car(car(cdr s-expr)))) |
Example | (cdaadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car(car s-expr))) |
Example | (cdaar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car(cdr(car s-expr)))) |
Example | (cdadar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car(cdr(cdr s-expr)))) |
Example | (cdaddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car(cdr s-expr))) |
Example | (cdadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(car s-expr)) |
Example | (cdar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(cdr(car(cdr s-expr)))) |
Example | (cddadr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(cdr(car s-expr))) |
Example | (cddar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(cdr(cdr(car s-expr)))) |
Example | (cdddar s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(cdr(cdr(cdr s-expr)))) |
Example | (cddddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(cdr(cdr s-expr))) |
Example | (cdddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns (cdr(cdr s-expr)) |
Example | (cddr s-expr) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns the list passed as argument less its first element |
Example | (cdr '(a b c)) => (b c) |
Function Type | subr |
Arguments | anything |
Return Value | an unsigned integer |
Description | returns the value of the cdr pointer of a lisp cell; the 4 less significant bits indicating the list, object and atom type of cells are masked so that the address is already 16 bytes aligned; the fifth bit which indicates the other types of cells is visible; in that case cdrvalue must be shifted by 5 bits to right and indicates the length of string and binary; an integer having cdr bits set indicates a special char read by ratom |
Example | (cdrvalue "hi" ) => 0x50 ; which shifted by 5 to right gives 2, which is the length of "hi" |
Function Type | subr |
Arguments | a string, and any number of string, symbolic atom, integer, unsigned integer or float |
Return Value | a string |
Description | formats using the C library function vsnprintf ; as each integer or pointer is promoted to long, this is transparent on a 32 bits CPU, but must be taken in account in the format on a 64 bits CPU (use 'l' modifiers) |
Example | (cformat "%s %f" "pi value" pi) => "pi value
3.141593" |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is a symbolic atom of which the property subr or fsubr exists; the value of such a property is a lisp cell of which car points to compiled code |
Example | (cfunctionp 'car) => t |
Function Type | expr |
Arguments | t or nil |
Return Value | t or nil |
Description | checks if a character has been unread on stdin; the optional argument sets the charInBuffer state of stdin to t or nil; char-in-buffer is an interpreted layer around the application of the more general symbolicstream-char-in-buffer method to stdin |
Example | (char-in-buffer) |
Function Type | subr |
Arguments | a string or a symbolic atom |
Return Value | the argument |
Description | changes the current directory of the process to the directory given as argument |
Example | (chdir ".." ) |
Function Type | subr |
Arguments | a list of integers |
Return Value | a string |
Description | returns a string made of the UTF-8 transformation applied to each integer of the argument list; if an integer does not contain a valid Unicode value, the character is replaced by a '?'; due to multi-byte characters the apparent printed string length is equal to the input list length, but the real length as shown by length can be longuer |
Example | (chr '(233 116 233)) => "été" |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | return t if the argument is a symbolic atom representing a class name |
Example | (classp 'symstream) => t |
Function Type | fsubr |
Arguments | a list of symbolic atoms, and any number of s-expr |
Return Value | anything |
Description | defines a lexical closure; each symbolic atom of the list given as first argument is copied as a free atom and given a copy of the plist of the original bound atom, but only the plist is a copy not the property-names nor the property-values which are really the original cells, thus shared with the original plist; so, when a form defined in the closure modifies a property, it acts only on the property list specific to the free symbol in the closure; as the free symbols are shared between all the forms of the closure, when one modifies a value or property, the other forms defined in the same closure see the same modifications; returns the last value like a progn block |
Example | (closure(a) (setq a "hello" ) (defun test nil a) ) => test (setq a "goodbye") => "goodbye" (test) => "hello" |
Function Type | subr |
Arguments | a string |
Return Value | an integer |
Description | executes the shell command given in the argument string and returns the return code value |
Example | (command "ls" ) |
Function Type | expr |
Arguments | a string |
Return Value | a string |
Description | executes the shell command given in the argument string and returns a string containing the first line written on its stdout by the child process; the absolute path of the command must be given; the function is quite equivalent to the shell backquote feature; the eventual newline is included in the resulting string |
Example | (command$ "/bin/date" ) => "Sun Apr 22 17:15:19 CEST 2007 " |
Function Type | subr |
Arguments | lists |
Return Value | a list or nil |
Description | returns a list made of concatenated copies of the arguments lists |
Example | (concat '(a b) '(c d)) => (a b c d) |
Function Type | fsubr |
Arguments | one or more clauses made each of a progn block |
Return Value | the last value of the executed clause or the value of the test |
Description | evaluates successively the first form of each clause, and as soon as a non-nil value is obtained, continues sequentially the evaluation of the forms of the clause; returns the value of the last form of the chosen clause |
Example | (cond ((= a b) (print "equal" )) ((> a b)(print "greater" )) (t(print "less" )) ) |
Function Type | subr |
Arguments | anything, a list or nil |
Return Value | a list |
Description | returns a list where the first element is the first argument, and the rest is the list given as second argument |
Example | (cons 'a '(b c)) => (a b c) |
Function Type | expr |
Arguments | one optional |
Return Value | nil |
Description | quits the debug mode, and skips the offending form; if the cause of the interruption has disappeared then the evaluation continues |
Example | (continue) |
Function Type | subr |
Arguments | two integers |
Return Value | an integer |
Description | weird Windows legacy function, supposed to control the precision of the floating point coprocessor, by calling the Win32 _controlfp function; defined only if wwlisp is compiled with -DLISPWIN32 |
Example | - |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns a list identical to the one given as argument, but made of completely new cells; even the sublists are duplicated; the atoms are not duplicated, just pointed to |
Example | (copyseq '(a b c)) => (a b c) |
Function Type | subr |
Arguments | a list, anything, an optional t or nil |
Return Value | an integer |
Description | returns the number of occurrences of the second argument in the first argument; if the optional third argument is given and non nil, the equality test used will be eq instead of = |
Example | (count '(a b c d e f d g h d) 'd) => 3 |
Function Type | fexpr |
Arguments | a list |
Return Value | an integer |
Description | returns the number of atoms in a form; no use outside being just a subroutine for readerprinter-pprint |
Example | - |
Function Type | fsubr |
Arguments | a symbolic atom, a list |
Return Value | the class name symbolic atom |
Description | defines and returns a new class of which the name is given by the first argument, and the ancestors or base classes by the list given as second argument; that second argument will become the baseclasses property of the new class; a lineage property is also added, which contains the list of all the ancestor classes of the new classes, made by exploring each base class by a depth-first strategy, pruning the duplicates and eliminating the loops; when a new object is constructed, the value of its baseclasses property is actually the value of the lineage property of the class of the new object; the object baseclasses property is used by eval to find which method should be applied, so if the inheritance hierarchy created by the depth-first strategy does not suits the need of the programmer, the hierarchy can be changed by manipulating directly the lineage property of the class; once an object has been constructed, that manipulation must occur on the baseclasses property of the object itself |
Example | (defclass symstream (readerprinter stream)) => symstream |
Function Type | fsubr |
Arguments | a symbolic atom, anything, a symbolic atom |
Return Value | a symbolic atom |
Description | defines for the symbolic atom given as first argument the property of which the name is given as third argument and the value given as second argument; returns the symbolic atom itself |
Example | (defprop 'life 42 'meaning) =>life |
Function Type | fsubr | |||||||||||||||
Arguments | a symbolic atom, an optional keyword fexpr or macro, a list, an unlimited number of forms | |||||||||||||||
Return Value | a symbolic atom | |||||||||||||||
Description | defines a function and returns its name; the function name is given as first argument, the arguments of the function is given as second argument, and the rest of the arguments are the forms which constitute the body of the function to be evaluated sequentially like in a progn block; per default, a function is of the type expr ; function of the type expr may have mandatory arguments, optional arguments marked by the keyword &optional and allthe following arguments grouped in a list after the keyword &rest ; the keyword fexpr indicates that the function does not evaluates its argument before entering the body and that all the arguments are linked in a unique list; the keyword macro indicates that the function does not evaluates its argument which are linked in a unique list and that the function body is supposed to generate a new form, which will then go through a second pass of evaluation in order to give the final result of the macro; the following table summarizes how the different function types evaluate their arguments before entering the body and spread their arguments on several symbols or not:
| |||||||||||||||
Example | (defun test (a b c &optional c d &rest e) (print (list a b c d e))) (test 1 2 3 4 5 6 7) => (1 2 3 4 5 (6 7)) |
Function Type | expr |
Arguments | a float |
Return Value | a float |
Description | returns the value of the argument given in radians expressed in degrees |
Example | (degree pi) => 180.000000 |
Function Type | subr |
Arguments | a list, anything, an optional t or nil |
Return Value | a list |
Description | returns a list where all occurrences of the second argument have been deleted from the first argument; the list returned is the modified original list, except for the first element which is just skipped if needed; if the optional third argument is given and non nil, the occurrence equality will be tested with eq instead of = |
Example | (delete '(a b c d) 'b) => (a c d) |
Function Type | subr |
Arguments | a list, a list, an integer, an optional integer |
Return Value | a list |
Description | makes a new list where the second argument has been deposited in the first argument at the position stated in the third argument up to the position before that stated in the fourth argument, or the length of the list to deposit if the fourth argument is not given, or the length of the list to deposit |
Example | (deposit '(a b c d e f) '(x y) 2 4) => (a b x y e f) |
Function Type | subr |
Arguments | an object, any number of arguments |
Return Value | anything |
Description | invokes the destructor for the class of the object passing the arguments if any beyond the first, and returns the result of the destructor; this function can be called by the garbage collector on objects which are not referenced anymore; a destructor might include the code to make the object permanent on some persistent storage |
Example | (destroy-instance myfile) |
Function Type | expr |
Arguments | a string |
Return Value | a list of directory entries |
Description | returns a list with all the entries read from the directory of which the name is passed as argument; if no name is passed, the current directory "." is assumed |
Example | (dir "." ) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is an object of class directory |
Example | (directoryp (make-instance directory "." )) => t |
Function Type | expr |
Arguments | an unsignedinteger |
Return Value | t or nil |
Description | returns t if the file attribute unsignedinteger given as argument, as read by directory-read-line, corresponds to a directory on the file system or not |
Example | (dirp 0x41ed) => t |
Function Type | expr |
Arguments | a string |
Return Value | nil |
Description | prints on stdout the result of dir, which gives the list of the directory of which the name is passed as argument |
Example | (dirprint "." ) |
Function Type | fsubr |
Arguments | a list, a list, an unlimited number of forms |
Return Value | anything |
Description | does a repetitive sequential evaluation of the forms given as arguments from the third one on as in a prog block; the first argument consists of a list of one or several clauses which define each a control variable, its initial value and a form which increments it, like (i 0 (+ 1 i)); the second argument consists of a clause containing first a form which tests a stopping condition for the do followed by forms to be evaluated sequentially before to quit the do , as in a progn block, the result of the do being the last result of the progn block; the third argument and all the following forms make up the body of the do , evaluated sequentially at each iteration; a go , return-from or throw executed anywhere in the initialization, the stopping test or in the body, with the intent to jumps non-locally outside of the do has its normally expected effect of transferring control and returning eventually a value; as the do is enclosed implicitely in a hidden prog block, a return from anywhere in any part of a do causes an immediate stopping of the do , returning whatever was given as argument to return ; go labels are allowed only in the body of the do because it is a prog block |
Example | (do ((i 0 (+ 1 i))) ((> i 5) 'finished) (prin1 i)) => 0 1 2 3 4 5finished |
Function Type | fexpr |
Arguments | a symbolic atom |
Return Value | nil |
Description | creates a temporary file in the directory ~/tmp under the name of the function given as argument, pretty-prints the function in the file, and then starts an editor with that file as argument; when the editing session is finished, the file is reloaded; edits also class definitions; when a function does not exists, an empty prototype is created and edited; pre-requisite: a tmp directory must exist in the user's home directory; by default the editor is kwrite or vi, following availability and executability, but the user can change that by modifying the edit function in init.lsp |
Example | (edit edit) => allows to modify the edit function itself |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the eighth element of the list passed as argument |
Example | (eighth '(a b c d e f g h i j)) => h |
Function Type | subr |
Arguments | an integer, a list |
Return Value | anything |
Description | return the element of the list given as second argument of which the place is given as first argument; the place of the first element is zero |
Example | (elt 2 '(a b c d)) =>c |
Function Type | subr |
Arguments | none |
Return Value | an unsigned integer |
Description | returns the address of the internal structure which contains all the data pertaining to the current wwlisp interpreter thread; the address is valid as long the thread runs; |
Example | (engineaddress) |
Function Type | subr |
Arguments | none |
Return Value | an integer |
Description | returns the interpreter version |
Example | (engineversion) => 8000 |
Function Type | expr |
Arguments | none |
Return Value | t or nil |
Description | returns (eof stdin); eof is an interpreted layer around the application of the more general symstream-eof method to stdout |
Example | (eof) |
Function Type | subr |
Arguments | anything, anything |
Return Value | t or nil |
Description | returns t if the two arguments represent the same identical thing, ie share the same memory location |
Example | (eq 42 42) => nil |
Function Type | subr |
Arguments | none |
Return Value | a form |
Description | returns the last form which has caused an error |
Example | (errform) |
Function Type | subr |
Arguments | a symbol |
Return Value | a string |
Description | returns the error message of which the symbolic index is passed as argument |
Example | (errmsg 'function-undefined) => "This function is not defined." |
Function Type | subr |
Arguments | none |
Return Value | an integer |
Description | returns a symbolic atom giving the system error code in human readable form; in version 8.000000 only a few functions and classes set it |
Example | (errno) |
Function Type | fexpr |
Arguments | none |
Return Value | nil or a two-elements list |
Description | performs the debugger loop; although it is possible to call this function explicitely, it is generally called directly by eval when an error has been encountered during evaluation; it is also called when control-c has been hit or when the break function has been executed; when in debug mode, several functions become useful: continue , retry , bt1 , bt2 and bt3 ; in order to quit the debugger and skip the offending form, type (continue) ; in order to quit the debugger and retry the offending form type (retry) ; the offending form can be corrected and passed as argument to retry , like (retry '(car mylist)) ; a simple native error function is compiled with the interpreter in order to provide a basic error handling when no init file is provided; the standard init.lsp which is normally loaded at start provides an interpreted error function with debugging capability; this function can be modified or replaced freely by the user; the error function is expected to return either nil or a two-elements list; returning anything else than a two-elements list does the same as executing (leave) , ie stop the evaluation and return to toplevel, even if several debugger invocations are nested; when returning a two-elements list, if the first element is nil , then the calling eval shall skip the offending form and continue the evaluation and if the first element is not nil , then the calling eval shall retry the offending form and then continue the evaluation; |
Example | ? (myfunction) *** The following form has caused an error... *** (myfunction) *** This function is not defined. Press ESC to leave or any other key to debug... Break(1)?? ? "try (help) or :help" Break(1)?? :help (inlist), (sort(inlist)) introspect and see all the symbols (edit [function]) edit a function or create a new one (browse [function]) browse an existing function (saveall [filename]) save all the new classes and functions (printall) print all the new classes and functions on lp (show [object]) pretty-print properties of an object ctrl-c: interrupt the evaluation and enter debug mode debug mode: (leave) abandon the debugging debug mode: (retry) retry the form after correction debug mode: (continue) skip the form in error debug mode: (bt1) backtrace with function names debug mode: (bt2) backtrace with full forms pretty-printed debug mode: (bt3) backtrace full forms reversed :[function] as in :bt1 shorter form for argument-less function (quit) stop the interpreter nil Break(1)?? (defun myfunction () 'hello) myfunction Break(1)?? (retry) hello ? |
Function Type | subr |
Arguments | a form |
Return Value | anything |
Description | evaluates the form given as argument and returns its result; because the function is a subr, the argument is evaluated a first time, then the result is passed to the body of eval which perform a second evaluation |
Example | (setq a 'b) (setq b 'c) (eval a) => c |
Function Type | expr |
Arguments | a list, a list |
Return Value | a list |
Description | returns a list containing all the elements present on only one of the two lists |
Example | (exclusion '(a b c d) '(c d x y z)) => (a b x y z) |
Function Type | expr |
Arguments | a form, a list |
Return Value | a list |
Description | returns a subset of the list given as second argument, where all the items match the criterium given as first argument; the criterium is a form protected by quote; the form must be a predicate applied to the symbol key and must return t if the record is to be retained |
Example | (extract '(lfunctionp key)(inlist)) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the fifth element of the list given as argument |
Example | (fifth '(a b c d e f g h i j)) => e |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class file or a subclass |
Example | (filep something) |
Function Type | expr |
Arguments | anything, a list |
Return Value | non-nil or nil |
Description | returns non-nil if the form given as first argument is found at least one time anywhere even in embedded sublists in the list given as second argument; no use, is just a subroutine for the function where |
Example | - |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | return the first element of the list given as argument |
Example | (first '(a b c d e f g h i j)) => a |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is a float |
Example | (floatp pi) => t |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the fourth element of the list given as argument |
Example | (fourth '(a b c d e f g h i j)) => d |
Function Type | subr |
Arguments | an unsigned integer |
Return Value | nil |
Description | frees the memory allocated via malloc |
Example | (setq seg(malloc 64)) (free seg) |
Function Type | subr |
Arguments | a form, an unlimited number of forms |
Return Value | anything |
Description | evaluates the first argument which must give a function name or lambda definition and then applies it to the following arguments |
Example | (funcall '(lambda (x y) (list x y)) ''a ''b) => (a b) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | return t if the argument is a symbol having a function property, ie is a function name |
Example | (functionp 'car) => t |
Function Type | expr |
Arguments | none |
Return Value | a symbol |
Description | creates and returns a new symbol each time that the function is called |
Example | (gensym) => g25 |
Function Type | subr |
Arguments | an integer |
Return Value | a string or nil |
Description | returns a string with the value of the command line argument of the interpreter of which the number is passed as argument to getargv |
Example | (getargv 0) => "wwlisp" |
Function Type | subr |
Arguments | a string |
Return Value | a string or nil |
Description | returns the value of the environment variable given as argument if found, nil otherwise |
Example | (getenv "TERM" ) => "xterm" |
Function Type | subr |
Arguments | a string |
Return Value | anything |
Description | returns the value of the interpreter option identified by the character given in the argument string; if no option was given at startup, the default value assumed during interpreter initialization is returned |
Example | (getoption "i" ) => "/usr/local/bin/init.lsp" |
Function Type | subr |
Arguments | none |
Return Value | an integer |
Description | returns the pid of the current process |
Example | (getpid) |
Function Type | subr |
Arguments | symbolic atoms |
Return Value | anything |
Description | returns the value of the property given as second argument from the atom passed as first argument |
Example | (getprop 'quit 'function) => (lambda fexpr nil(prog(_REP)(terpri stdout)(princ stdout "Are you sure ? (Y to
confirm) " )(setq _REP(chr(list(read-char-direct stdin))))(if(or(= _REP "Y" )(= _REP "y" ))(quit!)))) |
Function Type | subr |
Arguments | none |
Return Value | an integer |
Description | increments by one an intepreter-global integer and then returns its value; this counter can be used as token or handle to identify uniquely resources used by several threads, like messages sent via the thread messaging facility; a global gensym can be made of it |
Example | (globalcounter) => 1 |
Function Type | fsubr |
Arguments | a symbolic atom |
Return Value | none |
Description | stops immediately the evaluation in progress and jumps to the label given as argument in the closest embedding prog block; if no prog with the label is found, go unwinds the stack up to toplevel, where it stops with an error; go does not perform a real jump, but a sequential walk-through to find its target and is thus not the best way to program for performance; wwlisp being dynamically scoped, go can jump from one function to a label defined in a totally unrelated function which is just active at the moment of the go |
Example | (go exit) |
Function Type | expr |
Arguments | none |
Return Value | nil |
Description | prints a list of useful functions on stdout |
Example | (help) or :help |
Function Type | fsubr |
Arguments | a form, a form, an optional form |
Return Value | anything |
Description | evaluates the first form; if the result is non-nil, then evaluates the second form, otherwise evaluates the third form; returns the result of the form which was evaluated |
Example | (if t 1 2) => 1 |
Function Type | subr |
Arguments | none |
Return Value | a list |
Description | returns a list containing all the symbolic atoms defined in the environment; is the principal tool for introspection |
Example | (inlist) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class integer |
Example | (integerp 1) => t |
Function Type | expr |
Arguments | a list, a list |
Return Value | a list |
Description | returns a list containing all the elements which are present on the first and on the second lists passed as arguments |
Example | (intersection '(a b c d e f) '(d e f g h i)) => (d e f) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns a list containing just the last element of the list passed as argument |
Example | (last '(a b c d e)) => (e) |
Function Type | subr |
Arguments | none |
Return Value | none |
Description | causes the immediate abandon of the evaluation and to go back to toplevel without returning any value; can be used to quit debugging; objects which have been created and bound locally during the evaluation are lost in memory, and will only be destroyed properly, ie files or sockets closed, at the next garbage collection |
Example | (leave) |
Function Type | subr |
Arguments | a list |
Return Value | an integer |
Description | returns the length of the list passed as argument |
Example | (length '(a b c d e)) => 5 |
Function Type | subr |
Arguments | symbolic atom or string, symbolic atom or string |
Return Value | an integer |
Description | returns 0 if the two strings are lexically equal, 1 if the first is the lowest, 2 if the second is the lowest; the collating sequence is the ASCII character sequence, UTF-8 accented characters appearing after all the base characters |
Example | (lex "e" "é" ) => 1 |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | return t if the argument is a symbolic atom of which the property function is a lambda definition |
Example | (lfunctionp 'edit) => t |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class library or a child class of the class library |
Example | (libraryp libc) |
Function Type | subr |
Arguments | an unlimited number of anything |
Return Value | a list |
Description | returns a list made of the list of arguments |
Example | (list 'a 'b 'c 'd 'e) => (a b c d e) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of classes; all the classes are retrieved, as well those defined by the user than those loaded at initialization |
Example | (listallclasses) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of functions; all the functions are retrieved, as well those defined by the user than those loaded at initialization; as the methods pertaining to classes are also functions, they are also retrieved |
Example | (listallfunctions) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of classes; only the classes defined by the user are retrieved |
Example | (listclasses) |
Function Type | expr |
Arguments | a list of symbols |
Return Value | a list |
Description | when given a list of class names as argument, returns a list of the class names with each class followed by all the names of methods of the class; the compiled (subr, fsubr) methods are returned as well as the interpreted (expr, fexpr) |
Example | (listclassmethods '(library)) => (library library-call library-constructor library-destructor library-errmsg library-function-address) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which have a non-nil value property and are not functions or classes; there is no difference between symbols defined and bound during initialization or by the user: they are all retrieved |
Example | (listdata) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of classes or names of functions; only the classes and functions defined by the user are retrieved |
Example | (listfunclass) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of functions; as the methods pertaining to classes are also functions, they are also retrieved; only the functions defined by the user are retrieved; |
Example | (listfunctions) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of classes which were defined during initialization; the classes defined by the user are not retrieved |
Example | (listlibclasses) |
Function Type | expr |
Arguments | none |
Return Value | a list |
Description | returns a list of all the symbolic atoms which are names of functions which were defined during initialization; the functions defined by the user are not retrieved |
Example | (listlibfunctions) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is a list, nil otherwise; nil or (), the empty list, is also a list |
Example | (listp nil) => t |
Function Type | subr |
Arguments | a string, anything |
Return Value | t |
Description | loads the wwlisp file of which the name is given as first argument; the second argument defines the verbosity: if the second argument is omitted or t, the name of each function defined during loading is printed on stdout, and if the second argument is present and nil, the loading occurs silently; all the forms present in the file are evaluated, allowing the definition of classes, methods, functions and the initialization of symbols; nested load are allowed |
Example | (load "newapp.lsp" ) |
Function Type | subr |
Arguments | an unlimited number of forms |
Return Value | anything |
Description | evaluates sequentially all the forms given as arguments, repetitively; there is no stopping condition, a jump to the outside must be done to quit the loop; the loop block is totally similar to a prog block, so that go and return work and have the same effect; if no value is supplied by a return form, the loop form returns nil; |
Example | (loop (princ "hi! " )) |
Function Type | fsubr |
Arguments | a symbolic atom, an unlimited number of anything |
Return Value | an object |
Description | creates a simple empty wwlisp cell of the type object and the class given by the first argument, and then invokes the constructor of the class in order to add all the needed properties and finalize the construction; the rest of the argument list is passed to the constructor, which can be a subr, fsubr, expr or fexpr; returns the constructed object or nil if the construction failed; as per default an object cannot be printed on stdout by the standard symstream-print method, it often seems that make-instance fails and returns nil, but this is not the case and the return value must be checked with the function type, which return the class if the object has been built and nil if not before to be used as first argument of make-instance , the class must have been defined by defclass (defclass newclass (class)) the constructor must be of the form classname+hyphen+constructor, like: (defun newclass-constructor (arguments... ) (body... )) |
Example | (setq myfile(make-instance stream "textfile" "r" )) => nil (type myfile) => stream |
Function Type | subr |
Arguments | an integer |
Return Value | an unsignedinteger |
Description | allocates and clears to zero a heap segment and returns a pointer to it |
Example | (malloc 256) |
Function Type | subr |
Arguments | a function, an unlimited number of lists |
Return Value | a list |
Description | invokes iteratively the function given as first argument, be it a symbolic atom or a quoted lambda definition, on lists of arguments made each by taking the first element of each of the lists given as arguments to mapcan , then taking the second element, and so on; the list of arguments presented to the iterative function is thus as long as the number of lists given to mapcan ; mapcan ends when the first list has been exhausted; if one of the other list is shorter than the first, or even is totally ommitted, its corresponding argument is filled with nil; mapcan returns a list with the concatenated results of all the evaluations; if the results of each iteration are not lists suitables for concatenation, the nconc part of mapcan will throw an error |
Example | (defun test (a b c) (print (list a b c))) => test (mapcan 'test '(1 2 3 4) '(11 12 13) '(21 22)) => (1 11 21) (2 12 22) (3 13 nil) (4 nil nil) (1 11 21 2 12 22 3 13 nil 4 nil nil) |
Function Type | subr |
Arguments | a function, an unlimited number of lists |
Return Value | a list |
Description | invokes iteratively the function given as first argument, be it a symbolic atom or a quoted lambda definition, on lists of arguments made each by taking the first element of each of the lists given as arguments to mapcar , then taking the second element, and so on; the list of arguments presented to the iterative function is thus as long as the number of lists given to mapcar ; mapcar ends when the first list has been exhausted; if one of the other list is shorter than the first, or even is totally ommitted, its corresponding argument is filled with nil; mapcar returns a list with the results of all the evaluations |
Example | (defun test (a b c) (print (list a b c))) => test (mapcar 'test '(1 2 3 4) '(11 12 13) '(21 22)) => (1 11 21) (2 12 22) (3 13 nil) (4 nil nil) ((1 11 21)(2 12 22)(3 13 nil)(4 nil nil)) |
Function Type | subr |
Arguments | anything, a list, an optional t or nil |
Return Value | a list |
Description | looks for the first occurence of the first argument in the list given as second argument, and if found returns the rest of the list starting at that element; returns nil if not found; sublists are valid elements; if the optional third argument is given and non nil, the test used for equality will be eq instead of = |
Example | (member 'b '(a b c d)) => (b c d) |
Function Type | subr | ||||||||||||||||
Arguments | none | ||||||||||||||||
Return Value | a list | ||||||||||||||||
Description | returns a list with the current status of the thread memory; the elements are:
| ||||||||||||||||
Example | (memstat) => (2097152 169913 1048576 8746 1048576 0 157109) |
Function Type | subr |
Arguments | a string |
Return Value | a string |
Description | makes a new directory in the process current directory or in the path given in the argument |
Example | (mkdir "newdir" ) => "newdir" |
Function Type | subr |
Arguments | lists |
Return Value | a list |
Description | returns a list made of the concatenated lists given as arguments; the arguments are themselves modified, except the last list |
Example | (setq l1 '(a b c) l2 '(x y z)) (nconc l1 l2) => (a b c x y z) l1 => (a b c x y z) l2 => (x y z) |
Function Type | subr |
Arguments | a list, a list, an integer, an optional integer |
Return Value | a list |
Description | returns a modified list where the second argument has been deposited in the first argument at the position stated in the third argument up to the position before that stated in the fourth argument, or the length of the list to deposit if the fourth argument is not given, or the length of the list to deposit; the list given as first argument is itself modified |
Example | (ndeposit '(a b c d e f) '(x y) 2 4) => (a b x y e f) |
Function Type | expr |
Arguments | t or none |
Return Value | t or nil |
Description | returns t if stdout has just printed an atom; also sets it arbitrarily following the value t or nil of the argument; need-space is an interpreted layer around the application of the more general symbolicstream-need-space method to stdout |
Example | (need-space t) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the nineth element of the list passed as argument |
Example | (nineth '(a b c d e f g h i j)) => i |
Function Type | expr |
Arguments | a string |
Return Value | a string |
Description | does a substitution of all the characters giving problems when used in UNIX file names, by their names in full letters |
Example | (normalizefilename "$>/" ) => "dollargreaterthanslash" |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is nil or nil if the argument is non-nil |
Example | (not nil) => t |
Function Type | subr |
Arguments | an integer, a list |
Return Value | anything |
Description | returns the element of the list given as second argument, of which the number is given as first argument; the first element is element 1 |
Example | (nth 5 '(A B C D E F)) => E |
Function Type | subr |
Arguments | an integer, a list |
Return Value | a list |
Description | returns the part of the list given as second argument beginning from the element of which the number is given as first argument; the first element is element 1 |
Example | (nthcdr 5 '(A B C D E F)) => (E F) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | return t if the argument is nil or ommitted and nil if the argument is non-nil |
Example | (null t) => nil |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is an object instantiated from any class like float, integer, unsignedinteger, string, binary, stream, socket or any user-defined class or subclass; returns nil if the argument is an atom or a list |
Example | (objectp stdin) => t |
Function Type | fsubr |
Arguments | any s-expr in unlimited number |
Return Value | returns the value of the first non-nil argument or nil |
Description | evaluates all the arguments sequentially stopping at the first of which the value is non-nil; if the function reaches the end of the argument list, it returns nil |
Example | (or (member 'a '(a b c d)) (> pi 3)) => (a b c d) |
Function Type | subr |
Arguments | a symbolic atom or an object |
Return Value | a list |
Description | returns the property list of the symbolic atom or of the object; some properties are not directly printable and must be analyzed by indirect means |
Example | (plist 'car) => (function nil) (type(cadr(plist 'car))) => subr |
Function Type | subr |
Arguments | a list, anything, an optional t or nil |
Return Value | an integer or nil |
Description | returns the position of the form given as second argument in the list given as first argument; the first position is zero; returns nil if not found; if the optional third argument is given and non nil, the test used for equality will be eq instead of = |
Example | (position '(a b c d e f g h i j) 'e) => 4 |
Function Type | expr |
Arguments | an integer or a float |
Return Value | an integer or a float |
Description | returns the square of the argument |
Example | (power2 2) => 4 |
Function Type | expr |
Arguments | anything else than an object |
Return Value | the argument |
Description | prints the argument on stdout and also returns it; the argument is printed in such a way that it can be read back by a read function and give the same value; a string will be printed between double quote i.e. Unicode 34, and an atom containing special characters, i.e. a weird atom, will be printed between vertical bars i.e. Unicode 124; if a double quote occurs in a string, the double quote will be doubled, and if a vertical bar occurs in a weird atom, the vertical bar will be doubled; a list will be printed with the parenthesis and recursively, but infinite recursion or circular lists will throw errors; space characters will be added automatically as needed between atoms or values in order to avoid spurious apparent concatenations and errors while reading back; no newline will be issued at the end; prin1 is an interpreted layer around the application of the more general symbolicstream-prin1 method to stdout |
Example | (prin1 "hello" ) => "hello" "hello" |
Function Type | subr |
Arguments | anything |
Return Value | a string |
Description | prints the argument on a work string and returns the string; the argument is printed in such a way that it can be read back by a read function and give the same value; a string will be printed between double quote i.e. Unicode 34, and an atom containing special characters, i.e. a weird atom, will be printed between vertical bars i.e. Unicode 124; if a double quote occurs in a string, the double quote will be doubled, and if a vertical bar occurs in a weird atom, the vertical bar will be doubled; a list will be printed with the parenthesis and recursively, but infinite recursion or circular lists will throw errors; space characters will be added automatically as needed between atoms or values in order to avoid spurious apparent concatenations and errors while reading back; no newline will be issued at the end; prin1-to-string uses as work string a temporary object of the class symbolicstring , which is a subclass of the readerprinter class |
Example | (prin1-to-string '(a b c d e)) => "(a b c d e)" |
Function Type | expr |
Arguments | anything |
Return Value | the argument |
Description | prints the argument on stdout and also returns it; the argument is printed in such a way that strings and weird atoms are as they are, i.e. not enclosed by double quote or vertical bar respectively, and occurences of double quote or vertical bar are not doubled; a list will be printed recursively with the parenthesis, but infinite recursion or circular lists will throw errors; no space characters will be added between atoms or values, leading to spurious apparent concatenations while reading back; no newline will be issued at the end; princ is an interpreted layer around the application of the more general symbolicstream-princ method to stdout |
Example | (princ "hello" ) => hello"hello" |
Function Type | subr |
Arguments | a string |
Return Value | a string |
Description | prints the argument on a work string and returns the string; the formatting of an argument of another type than string is not documented; the argument is printed in such a way that strings and weird atoms are as they are, i.e. not enclosed by double quote or vertical bar respectively, and occurences of double quote or vertical bar are not doubled; a list will be printed recursively with the parenthesis, but infinite recursion or circular lists will throw errors; no space characters will be added between atoms or values, leading to spurious apparent concatenations while reading back; no newline will be issued at the end; princ-to-string uses as work string a temporary object of the class symbolicstring , which is a subclass of the readerprinter class |
Example | (princ-to-string '(a b c d e)) => "(abcde)" |
Function Type | expr |
Arguments | anything else than an object |
Return Value | the argument |
Description | prints the argument on stdout and also returns it; the argument is printed in such a way that it can be read back by a read function and give the same value; a string will be printed between double quote i.e. Unicode 34, and an atom containing special characters, i.e. a weird atom, will be printed between vertical bars i.e. Unicode 124; if a double quote occurs in a string, the double quote will be doubled, and if a vertical bar occurs in a weird atom, the vertical bar will be doubled; a list will be printed with the parenthesis and recursively, but infinite recursion or circular lists will throw errors; space characters will be added automatically as needed between atoms or values in order to avoid spurious apparent concatenations and errors while reading back; a newline will be issued at the end; print is an interpreted layer around the application of the more general symbolicstream-print method to stdout |
Example | (print "hello" ) => "hello" "hello" |
Function Type | expr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is either an interpreted function name or a class name, and thus printable |
Example | (printablep 'edit) => t |
Function Type | expr |
Arguments | none |
Return Value | the symbol 'printed |
Description | pretty-prints all the printable and saveable classes and functions in a file named $HOME/tmp/lispspool; the classes and functions are sorted in the normal collating sequence, each class definition preceding the related methods; the file is finally printed by the lp command; the classes and functions loaded during initialization are marked with a property nosave t which prevents to save them along with new definitions made by the user and also prevent them to be printed |
Example | (printall) |
Function Type | fexpr |
Arguments | an unlimited number of class names |
Return Value | the symbol 'printed |
Description | pretty-prints all the classes of which the names are passed as arguments and their printable methods in a file named $HOME/tmp/lispspool; the classes and functions are sorted in the normal collating sequence, each class definition preceding the related methods; the file is finally printed by the lp command; the classes and methods loaded during initialization are also printed; if printclasses is invoked a second time without arguments, it reuses automatically the previous arguments |
Example | (printclasses class) |
Function Type | fexpr |
Arguments | an unlimited number of function names |
Return Value | the symbol 'printed |
Description | pretty-prints all the functions of which the names are passed as arguments, if they are printable, in a file named $HOME/tmp/lispspool; the functions are sorted in the normal collating sequence; the file is finally printed by the lp command; the functions loaded during initialization are also printed; if printfunctions is invoked a second time without arguments, it reuses automatically the previous arguments |
Example | (printfunctions edit) |
Function Type | expr |
Arguments | a list of symbols, a filename |
Return Value | nil |
Description | prints in the file given as second argument all the symbols of the list given as first argument followed by their property list; if the second argument is omitted, the result is printed on stdout; this function is just a crude debugging helper |
Example | (printlist(inlist)) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class process or a subclass |
Example | (processp child) => t |
Function Type | fexpr |
Arguments | a form |
Return Value | nil |
Description | counts the calls of each and every function used during the evaluation of the form passed as argument, and prints a ranking report on stdout |
Example | (profile (mytest)) |
Function Type | fsubr |
Arguments | a list of symbols, an unlimited number of forms |
Return Value | anything |
Description | defines a block of forms evaluated in sequence, with the possibility of local jumps; before to begin the evaluation of the second and further arguments, the symbols given in the first argument are disconnected of their current properties which are saved; then the arguments are evaluated; after the last evaluation, before to quit the prog block, the symbols given in the first argument are rebound to their original properties and the properties defined during the prog block are discarded; an argument form to the prog can be an unquoted symbolic atom, which can be used as tag for a go form; one can jump outside a prog by using go or return , the last with an optional argument which will become the return value of the prog block |
Example | (prog(a) (setq a 1) redo (if (> a 10)(return a)) (setq a(+ 1 a)) (go redo) ) => 11 |
Function Type | fsubr |
Arguments | an unlimited number of forms |
Return Value | anything |
Description | evaluates successively each form given as argument and returns as result the value of the first form evaluated |
Example | (prog1(setq a 1)(setq b 2)(setq c 3)) => 1 |
Function Type | fsubr |
Arguments | an unlimited number of forms |
Return Value | anything |
Description | evaluates successively each form given as argument and returns as result the value of the first form evaluated |
Example | (prog2(setq a 1)(setq b 2)(setq c 3)) => 2 |
Function Type | fsubr |
Arguments | an unlimited number of forms |
Return Value | anything |
Description | evaluates successively each form given as argument and returns as result the value of the first form evaluated |
Example | (progn(setq a 1)(setq b 2)(setq c 3)) => 3 |
Function Type | subr |
Arguments | a symbolic atom, anything, a symbolic atom |
Return Value | anything |
Description | defines for the symbolic atom given as first argument the property of which the name is given as third argument and the value given as second argument; returns the value given as second argument |
Example | (putprop 'life 42 'meaning) => 42 |
Function Type | fexpr |
Arguments | none |
Return Value | none |
Description | asks confirmation to quit and if Y is entered, quits immediately any evaluation and the toplevel loop, and stops the interpreter, returning 0 as return code; unreferenced but still existing objects are not properly destroyed by quit , but a call to recycle before to quit invokes the adequate destructors |
Example | (quit) |
Function Type | fsubr |
Arguments | anything |
Return Value | anything |
Description | returns its unevaluated argument; the purpose of this function is to protect its argument against evaluation; thanks to the readmacro mechanism, the form (quote arg) has a shorter equivalent: 'arg |
Example | (quote (a b c d)) => (a b c d) '(a b c d) => (a b c d) |
Function Type | expr |
Arguments | a float |
Return Value | a float |
Description | converts an angle given in degree to radian |
Example | (radian 180.0) => 3.141593 |
Function Type | subr |
Arguments | an integer or unsignedinteger |
Return Value | t |
Description | reinitialize the random seed with the integer given as argument |
Example | (random-state 1000) |
Function Type | subr |
Arguments | none |
Return Value | an atom |
Description | reads stdin and returns the next token; the token can be a symbolic atom, a weird atom enclosed in vertical bars, a double precision floating point real number, a signed integer or an unsigned integer, or an instance of the class specialchar; the special character is represented by an object of the class specialchar of which the value is the Unicode value of the character, allowing the use of accented and international characters as special characters for readmacros or separators; ratom is seldom used by itself but is generally used by the read function; ratom uses the more fundamental read-char and unread-char methods which must be inherited from a parent class |
Example | (setq token(ratom)) (cond((specialcharp token) ... special character handling ...) (t ... all other tokens handling ...) ) |
Function Type | expr |
Arguments | none |
Return Value | anything |
Description | reads stdin and returns the next wwlisp form; the form can be a symbolic atom, a weird atom enclosed in vertical bars, a string enclosed in double quotes, a double precision floating point real number, a signed integer or an unsigned integer, or a list structure eventually also made recursively of sublists; the form is ready to be evaluated by passing to eval ; read is one of the components of the toplevel loop read-eval-print; read uses ratom to fetch the next token on the input, and if the token is a special character, read looks into the property readmacro of stdin for the corresponding form to execute; a special character and its readmacro can be redefined or inhibited by the function set-macro-char ; read is an interpreted layer around the application of the more general symbolicstream-read method to stdin |
Example | (read) |
Function Type | expr |
Arguments | none |
Return Value | an integer |
Description | reads a UTF-8 character on the input buffer of stdin; if stdin is a terminal and the input buffer is empty, an internal readline is initiated on the terminal, blocking the interpretation, which allows to recall lines from keyboard history with up and down arrows, and the editing of the line with insert, delete, backspace, left and right arrow keys, and entry of the line with the return or enter keys; if the data entered by the keyboard is longuer than the maxStringLength set at startup, an automatic enter is performed, transmitting the buffer to read-char and allowing the interpretation to continue; the UTF-8 sequences are interpreted by a finite state automaton until complete and returned as one Unicode integer; read-char is an interpreted layer around the application of the more general symbolicstream-read-char method to stdin |
Example | (read-char) |
Function Type | expr |
Arguments | none |
Return Value | an integer |
Description | reads an UTF-8 character directly on stdin, without to use the input buffer; there is no echo on stdout; escape sequences like movement keys are perceived as several separated characters which must be interpreted by the application; UTF-8 sequences are interpreted by a finite state automaton until complete and returned as one Unicode integer; read-char-direct is an interpreted layer around the application of the more general symbolicstream-read-char-direct method to stdin |
Example | (read-char-direct) |
Function Type | subr |
Arguments | a string |
Return Value | anything |
Description | reads the string given as argument and returns a wwlisp form; the form can be a symbolic atom, a weird atom enclosed in vertical bars, a string enclosed in double quotes, a double precision floating point real number, a signed integer or an unsigned integer, or a list structure eventually also made recursively of sublists; newline and other whitespace characters embedded in the input string are properly skipped; the form is ready to be evaluated by passing to eval ; read-from-string uses ratom to fetch the next token on the input string, and if the token is a special character, read-from-string looks into the property readmacro of the temporary symbolicstring object for the corresponding form to execute; a special character and its readmacro can be redefined or inhibited by the function set-macro-char ; the object used by read-from-string as work string is an object of the class symbolicstring , which is a subclass of the readerprinter class |
Example | (read-from-string "(a b c d e)" ) => (a b c d e) |
Function Type | expr |
Arguments | none |
Return Value | a string |
Description | reads stdin and returns the next line as a string; the line read goes from the current position in the input buffer to just after the newline character, but the newline character is deleted from the string returned; read-line is an interpreted layer around the application of the more general symbolicstream-read-line method to stdin |
Example | (read-line) |
Function Type | subr |
Arguments | a string |
Return Value | a string |
Description | reads stdin and returns the result as a string; the string read goes from the current position in the input buffer to just before and not including the first of the delimiting UTF-8 characters found in the string given as second argument; the delimiting character is deleted from the input and will not be read again by the following call; readerprinter-read-string works by calling iteratively on the object the more fundamental methods read-char and unread-char , which must be inherited from a parent class |
Example | (read-string stdin "€" ) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is an object of a class inheriting from readerprinter |
Example | (readerprinterp stdin) => t |
Function Type | subr |
Arguments | none |
Return Value | nil |
Description | forces a garbage collection on the pointer segment; a first phase consists in marking all the cells which are reachable, i.e. connected to the global environment of the thread, or on special lists like the catch stack or the protection stack; then a sweep occurs, gathering all the unmarked cells which are not objects and resetting the marks; finally, the destructors are called for all the unreferenced objects; hence, when during evaluation a living object is per accident unbound and becomes unreachable, one can anyway force its proper destruction by issuing a recycle |
Example | (recycle) |
Function Type | subr |
Arguments | none |
Return Value | nil |
Description | forces a garbage collection on the binary segment; first a garbage collection is done on the pointer segment, releasing all the unreferenced wwlisp cells; then a new binary segment is allocated and all the binary objects still referenced are copied consecutively on the new segment compacting it and releasing holes, and finally the old segment is returned to the process heap; if a binary block was allocated somewhere else than on the old segment, it is not moved and remain where it was; as garbage collection moves the binary blocks, do not take their address as constant |
Example | (recycle-binary) |
Function Type | subr |
Arguments | none |
Return Value | nil |
Description | forces a garbage collection on the string segment; first a garbage collection is done on the pointer segment, releasing all the unreferenced wwlisp cells; then a new string segment is allocated and all the print names of the symbolic atoms and string objects still referenced are copied consecutively on the new segment compacting it and releasing holes, and finally the old segment is returned to the process heap; if a string was allocated somewhere else than on the old segment, it is not moved and remain where it was; as garbage collection moves the strings, do not take their address as constant |
Example | (recycle-string) |
Function Type | subr |
Arguments | a list, anything, an optional t or nil |
Return Value | a list |
Description | returns a list where all occurrences of the second argument have been deleted from the first argument; the list returned is a new one, the original list remaining unchanged; if the optional third argument is given and non nil, the occurrence equality will be tested with eq instead of = |
Example | (remove '(a b c d) 'b) => (a c d) |
Function Type | subr |
Arguments | a symbolic atom, a symbolic atom |
Return Value | nil |
Description | removes the property given as second argument from the atom given as first argument |
Example | (remprop 'symbol1 'property1) => nil |
Function Type | expr |
Arguments | one optional |
Return Value | nil |
Description | quits the debug mode, and retries the offending form; if a form is given as argument, it is evaluated instead of the form which caused the interruption; if the cause of the interruption has disappeared then the evaluation continues |
Example | (retry) |
Function Type | subr |
Arguments | optional anything |
Return Value | none |
Description | stops immediately the evaluation in progress and unwinds the stack until it gets out of the innermost enclosing prog block, i.e. prog , loop , do body; the result of the prog block becomes the value given as argument to return ; if no prog block was active at the moment of the call to return , the unwinding proceeds up to toplevel, where an error is thrown; wwlisp being dynamically scoped, return can jump from one function to a prog block defined in a totally unrelated function which is just active at the moment of the return |
Example | (return 'finished) |
Function Type | subr |
Arguments | optional symbol, optional anything |
Return Value | none |
Description | stops immediately the evaluation in progress and unwinds the stack until it gets out of the innermost enclosing prog block, i.e. prog , loop , do body, or progn block, i.e. progn , prog1 , prog2 , do return clause, function body, of which the name is passed as first argument; the result of the prog or progn block becomes the value given as second argument to return-from ; if no suitably named prog or progn block was active at the moment of the call to return-from , the unwinding proceeds up to toplevel, where an error is thrown; wwlisp being dynamically scoped, return-from can jump from one function to a prog or progn block defined in a totally unrelated function which is just active at the moment of the return-from ; return-from is best used as a way of exiting of a function body, avoiding the need of a prog form; if no first argument is supplied, return-from acts exactly as return and stops the innermost enclosing prog block |
Example | (return-from 'myfunction 33) |
Function Type | subr |
Arguments | a list |
Return Value | a list |
Description | returns a new list equivalent to the one given as argument but in reversed order; the elements are the same, i.e. eq returns t on each of them; the original list is not modified |
Example | (reverse '(a b c d e f)) => (f e d c b a) |
Function Type | subr |
Arguments | a string or symbolic atom |
Return Value | the argument |
Description | removes the directory given as argument from the system |
Example | (rmdir "mydir" ) => "mydir" |
Function Type | subr |
Arguments | a list, anything |
Return Value | a list |
Description | replaces the car value of the first wwlisp cell of the list given as first argument by the second argument and returns the modified list; as this modifies a cell in place, this operation can build a infinite recursivity of embedded sublists, which will throw an error while printing |
Example | (setq x '(a b c d e)) (rplaca x x) |
Function Type | subr |
Arguments | a list, a list |
Return Value | a list |
Description | replaces the cdr value of the first wwlisp cell of the list given as first argument by the second argument and returns the modified list; as this modifies a cell in place, this operation can build a circular reference loop, which will throw an error while printing or evaluating the length |
Example | (setq x '( a b c)) (rplacd x x) |
Function Type | fexpr |
Arguments | a string |
Return Value | the symbol 'saved |
Description | open the text file of which the path and name is given as argument and pretty-prints all the classes, methods and functions found in the current environment; the classes, methods and functions loaded from the file init.lsp have a property nosave t which prevents them to be saved; the filename is recorded in a global variable, in such way that a second invocation of saveall but without argument overwrites the output file |
Example | (saveall "newapp.lsp" ) |
Function Type | fexpr |
Arguments | a string |
Return Value | the symbol 'saved |
Description | open the text file of which the path and name is given as argument and pretty-prints all the classes, methods and functions found in the current environment; even the classes, methods and functions loaded from the file init.lsp are saved |
Example | (saveall2 "total.lsp" ) |
Function Type | fexpr |
Arguments | a string, an unlimited number of symbolic atoms |
Return Value | the symbol 'saved |
Description | open the text file of which the path and name is given as first argument and pretty-prints all the classes given as second and further arguments and their methods found in the current environment; the classes and methods loaded from the file init.lsp have a property nosave t which prevents them to be saved; the argument list is recorded in a global variable, in such way that a second invocation of saveclasses without any argument redoes the save operation overwriting the output file |
Example | (saveclasses "newclass.lsp" newclass) |
Function Type | fexpr |
Arguments | a string, an unlimited number of symbolic atoms |
Return Value | nil |
Description | open the text file of which the path and name is given as first argument and prints each symbol given as second and further arguments, followed by their value, in such a way that when the file is loaded, the same symbol retrieves the same value |
Example | (savedata "datafile" a b c d) |
Function Type | fexpr |
Arguments | a string, an unlimited number of symbolic atoms |
Return Value | the symbol 'saved |
Description | open the text file of which the path and name is given as first argument and pretty-prints all the functions given as second and further arguments found in the current environment; the functions loaded from the file init.lsp have a property nosave t which prevents them to be saved; the argument list is recorded in a global variable, in such way that a second invocation of savefunctions without any argument redoes the save operation overwriting the output file |
Example | (savefunctions "newfunc.lsp" func1 func2 func3) |
Function Type | expr |
Arguments | a symbol |
Return Value | a symbol |
Description | pretty-prints a single function in an already opened stream object; do not use that function directly, it is a subroutine common to most of the save functions |
Example | none |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is a number, either integer or float |
Example | (scalarp pi) => t |
Function Type | subr |
Arguments | a list, a list, an optional t or nil |
Return Value | an integer |
Description | returns the position where the list given as second argument begins in the list given as first argument; returns nil if the second argument is not found in the first; the first position is the position zero; the function search tries to locate a sequence, in contrast with position which tries to locate an element; if the optional third argument is given and non nil, then the test used for equality will be eq instead of = |
Example | (search '(a b c d e f) '(c d)) => 2 |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the second element of the list given as argument |
Example | (second '(a b c d e f g h i j)) => b |
Function Type | subr |
Arguments | none |
Return Value | none |
Description | causes a segmentation violation and allows to test the trapping mechanism; this function is only defined if the interpreter has been compiled with -D_DEBUG |
Example | (segv) |
Function Type | subr |
Arguments | a list of keywords each followed by a value |
Return Value | t or nil |
Description | waits for the availability of one or more objects of the file class (of which socket and stream are subclasses); when an object is available for reading, writing or exception processing, the callback defined for the object will be called automatically; the keyword 'read followed by a list of sockets or streams defines which objects must be watched for the possibility to read without waiting, ie where data are available; the keyword 'write followed by a list of sockets or streams defines which objects must be watched for the possibility to write without waiting, ie where the buffer is empty; the keyword 'except followed by a list of sockets defines which objects must be watched for the possibility to process out-of-band data by using recv and send with the flag value MSG_OOB and buffer size of 1; select processes first the 'except callbacks, then the 'read and finally the 'write ; the 'timeout keyword followed by a float or an integer defines in milliseconds how long the select function must wait for an event; a timeout of zero causes the function to return immediately without waiting, which is useful for polling, and no timeout causes the function to wait indefinitely; the select function returns t if successfull; if a callback performs a non-local jump to a catch or go label out of the select scope, the remaining events are not processed but the next select on the same objects will get them; an error is thrown if one tries to watch for a socket or stream without adequate callback; the callbacks are specified and set directly on each object by calling the set* methods of the file class. it is also possible, instead, to define generic callbacks for the object classes, provided these are named with the class name followed by -exceptproc , -readproc or -writeproc ; see also the classes file , stream , socket . |
Example | (defun file-exceptproc() ...) ; generic class except callback (defun file-readproc() ...) ; generic class read callback (set-write-proc s1 'wp1) ; attach wp1 to s1 as write-callback (set-write-proc s2 'wp2) ; attach wp2 to s2 as write-callback (select 'read (list s1 s2) 'write (list s1 s2) 'except (list s1 s2) 'timeout 60000) |
Function Type | subr |
Arguments | a symbol, anything |
Return Value | the second argument |
Description | sets the value of the first argument to the value of the second argument; as both arguments are first evaluated, the first must be quoted or contain as value the symbol to be really set; the first argument can also be or evaluate to an object instantiated from a class; the value of the symbol or object which is set is actually stored as the value of the value property of the symbol or object; the function returns the second argument |
Example | (set 'a 'b) => b a => b |
Function Type | subr |
Arguments | a symbol or an object, a symbol, a form |
Return Value | t |
Description | sets a new formatter, changes an existing formatter or clears an existing formatter; as the formatting mechanism is a feature of the readerprinter class, the first argument must be '*readtable* or an existing object inheriting the readerprinter class; the second argument must be a class name (symbolic atom); the third argument must be a function name (symbolic atom) or a lambda function definition; if the third argument is nil, then the formatter for that class is removed from the object; when a new object is instantiated from a class inheriting from readerprinter , its constructor copies all the formatters stored in *readtable*, but it is always possible to modify dynamically the formatting rules of a readerprinter object by calling set-formatter later on it; any change on *readtable* does not modify the behaviour of the already instantiated readerprinter objects, that's why one must apply set-formatter directly on such objects; if no formatter has been defined for a specific class to be printed, then the default formatter of the class will be used; |
Example | (set-formatter '*readtable* 'float '(lambda(x)(cformat "%.9lf" x))) => t |
Function Type | subr |
Arguments | a symbol or an object, an integer, a form |
Return Value | t |
Description | sets a new readmacro, changes an existing readmacro or clears an existing readmacro; as the readmacro mechanism is a feature of the readerprinter-read method, the first argument must be '*readtable* or an existing object inheriting the readerprinter class; when a new object is instantiated from a class inheriting from readerprinter , its constructor copies all the readmacros stored in *readtable*, but it is always possible to modify dynamically the parsing rules of a readerprinter object by calling set-macro-char later on it; any change on *readtable* does not modify the behaviour of the already instantied readerprinter objects, that's why one must apply set-macro-char directly on such objects |
Example | (ord "€" ) => (8364) ; Unicode value of € (set-macro-char '*readtable* 8364 '(progn(read-line this)(read this))) => sets € as general comment macro (set-macro-char stdin 8364 '(progn(read-line this)(read this))) => sets € as comment macro for stdin |
Function Type | subr |
Arguments | a symbol or an object, a list of symbols or lambda functions |
Return Value | a list |
Description | sets or replaces the scanner list; the first argument must be '*readtable* or an existing object inheriting the readerprinter class; when a new object is instantiated from a class inheriting from readerprinter , its constructor copies the scanner property of *readtable*, but it is always possible to modify dynamically the scanner property of a readerprinter object by calling set-scanner later on it; any change on *readtable* does not modify the behaviour of the already instantied readerprinter objects, that's why one must apply set-scanner directly on such objects; the list given as second argument must contain recognizers functions, either names or lambda definitions; these recognizers functions will be called each after the other, in the sequence of the list, and presented with a string containing the token delimited by readerprinter-ratom , until one of the recogizers returns a valid object instead of nil; if no valid object has been returned, readerprinter-ratom assumes that the token is a symbolic atom |
Example | (set-scanner '*readtable* '(scan-number scan-binary)) => (scan-number scan-binary) |
Function Type | subr |
Arguments | a string, a string |
Return Value | t or nil |
Description | sets an environment variable given as first argument to the value given as second argument; returns t if the variable was effectively set and nil in case of error; the environment variable is then visible for the process itself and its children |
Example | (setenv "myvar" "myvalue") => t |
Function Type | fsubr |
Arguments | an unlimited list of pairs of one symbol and one form |
Return Value | the second argument |
Description | in each pair of arguments, sets the symbol given as odd argument to the value given as even argument; only the even arguments are evaluated, the odd ones must be symbols |
Example | (setq a 'b c 'd)=> b a => b c => d |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the seventh element of the list passed as argument |
Example | (seventh '(a b c d e f g h i j)) => g |
Function Type | expr |
Arguments | none |
Return Value | nil |
Description | prints on stdout a human readable report about memory occupation |
Example | (showstats) pointer space cells = 2097152 pointer cells used = 249614 string space bytes = 1048576 string space used = 11925 binary space bytes = 1048576 binary space used = 0 free recycled cells = 0 stack base address = 0xc0000000 stack top address = 0xbfffea47 maximum lisp stack = 0xbe000cbb segment limit addr. = 0x42494000 stack segment size = 2109128704 nil |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the sixth element of the list passed as argument |
Example | (sixth '(a b c d e f g h i j)) => f |
Function Type | subr |
Arguments | an integer |
Return Value | nil |
Description | pauses the thread by the number of milliseconds given as argument |
Example | (sleep 1000) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class socket or a subclass |
Example | (socketp something) |
Function Type | subr |
Arguments | a list, an optional collating function |
Return Value | a list |
Description | sorts the list given as first argument; if a second argument is provided, it must be a function which receives two arguments and returns t when they are already in the chosen collating sequence, and nil when they must be swapped to respect it; if sort does not receive a second argument, it uses a default collating sequence corresponding to the type of the cell first, and for equal type string or numeric comparison; in case of integers and float mixed, they are thus not sorted as real numbers; to properly sort items of different types, the user must provide a collating function |
Example | (defun seq fexpr(args) (>(string(car args))(string(cadr args)))) (seq b a) => t (sort '(a b c d e f) 'seq) => (f e d c b a) |
Function Type | subr |
Arguments | none |
Return Value | a list |
Description | returns a list giving the stack base address, the current top-of-stack address, the lisp allowed max stack address, the system allowed max stack address, and the system stack size of the calling thread; commonly, the stack increases by decreasing the address of the TOS pointer, so 'max address' means 'lowest address'; the addresses are expressed in unsigned integers |
Example | (stackstat) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class stream or a subclass |
Example | (streamp something) |
Function Type | subr |
Arguments | one of any type |
Return Value | t or nil |
Description | returns t if the argument is of the class string directly or by inheritance (ie: is a subclass of) |
Example | (stringp (make-instance string 4)) => t |
Function Type | subr |
Arguments | a symbolic atom |
Return Value | a string |
Description | returns a string containing the print name of the symbolic atom; as a method of the same name exists for each of the classes integer, unsignedinteger and float, this allows a transparent conversion of any of those types in a string with the same code |
Example | (string 3.14) => "3.140000" (string 'hello) => "hello" |
Function Type | subr |
Arguments | a list, an integer, an optional integer |
Return Value | a list or nil |
Description | returns a list extracted from the first argument starting at the position given as second argument, and ranging up to the position just before the one given as third argument; if no third argument is provided, the extraction goes up to the end of the first argument; returns nil if there is nothing to extract at the required positions; first position is at 0 |
Example | (subseq (inlist) 0 10) => (binaryp stream-fread thread-signal stdin xx plist float-max second binary-float defclass) |
Function Type | subr |
Arguments | anything, anything, a list |
Return Value | a list |
Description | returns a copy of the list given as third argument, where all the occurrences of the second argument are replaced by copies of the first argument; even embedded sublists are tested and replaced; the test used for equality is always = |
Example | (subst '(bread and water) '(control and security) '(The World needs more(control and security)) => (The World needs more(bread and water)) |
Function Type | subr |
Arguments | anything, anything, a list, an optional anything |
Return Value | a list |
Description | returns a copy of the list given as first argument where all occurences of the third argument have been replaced by the second argument; the total length of the resulting list can be modified, as the target and substitution can be of different lengths; the test and replacement will occur only at the first level of depth, not in sublists; if the optional fourth argument is given and non nil, then the test used for equality will be eq instead of = |
Example | (substitute '(The World needs more peace and love) 'country 'World) => (The country needs more peace and love) |
Function Type | subr |
Arguments | a string |
Return Value | a symbolic atom |
Description | returns a symbolic atom of which the name is the text of the string; the new atom is also linked to the environment and can be bound to properties; if the atom was already present in the environment, symbol just returns a pointer to it; if we are certain that a string string1 contains just a name, then (symbol string1) does the same as (read-from-string string1) but in a far shorter and faster way |
Example | (symbol "newatom" ) => newatom |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class symbolicsocket or a subclass |
Example | (symbolicsocketp something) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class symbolicstream or a subclass |
Example | (symbolicstreamp something) |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is an object of the class symbolicstring |
Example | (symbolicstring *symbolicstring*) => t |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is a symbolic atom and nil otherwise |
Example | (symbolp 'car) => t |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | returns the tenth element of the list passed as argument |
Example | (tenth '(a b c d e f g h i j)) => j |
Function Type | expr |
Arguments | none |
Return Value | nil |
Description | prints a newline character on stdout; terpri is an interpreted layer around the application of the more general symstream-terpri method to stdout |
Example | (terpri) |
Function Type | subr |
Arguments | a list |
Return Value | anything |
Description | turns the third element of the list passed as argument |
Example | (third '(a b c d e f g h i j)) => c |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class thread or a subclass |
Example | (threadp something) |
Function Type | subr |
Arguments | a mandatory symbol, an optional value or nil, an optional function name |
Return Value | none |
Description | throw causes a non local jump depending on several conditions; the first argument must be a symbolic atom and represent the label of the catch up to which the control must be unwound; the second argument is the return value of the catch intercepting the throw; the third argument is an optional function name; throw will unwind the stack up to the nearest catch with the specific label, or by default to the nearest catch with an any-condition label; if the first argument is an error index, and the third argument is given and is the name of a function currently in scope, no catch is sought but the stack is unwound up to the named function, in order to simulate a native interpreter error; such an error can furthermore be caught by a catch with the same label; this mechanism gives the possibility to raise standard errors on behalf of the user code; if there is no catch in the current scope with a label equal to the label given as first argument to the throw, and none of the special cases listed above applies, then an error is thrown, which by implementation choice cannot be caught, ie. one cannot catch a missing catch ... |
Example | ? (terpri 'thing) *** The following form has caused an error... *** (terpri 'thing) *** Incorrect number of arguments. Press ESC to leave or any other key to debug... ? (errmsg 12) "Incorrect number of arguments." ? (catch 'error-12 (terpri 'thing)) nil |
Function Type | subr |
Arguments | none |
Return Value | t |
Description | activates the tracing; from that moment on, each time the evaluator enters a function, a message 'enter <function name>' will be printed on stderr, and each time the evaluator returns from a function, a message 'leave <function name>' will be printed on stderr |
Example | (trace) |
Function Type | subr |
Arguments | mandatory of any type |
Return Value | a symbol or nil |
Description | returns the class name of the argument; a list has no class and the function returns nil in that case |
Example | (type 1) => integer |
Function Type | fexpr |
Arguments | a symbol |
Return Value | nil |
Description | makes the function of which the name is given as argument undefined, ie removes the function property of the symbolic atom; the other properties of the atom are left inchanged |
Example | (undef myfunc) |
Function Type | expr |
Arguments | none |
Return Value | nil |
Description | undefines all the user defined classes and functions |
Example | (undefall) |
Function Type | expr |
Arguments | a list, a list |
Return Value | a list |
Description | returns a list containing no more than one time each element of each of the two lists given as arguments, performing a union set operation |
Example | (union '(a b c) '(b c d e)) => (a b c d e) |
Function Type | macro |
Arguments | a list, an optional sequence of s-expr |
Return Value | returns the value of the last s-expr |
Description | evaluates the first argument and if false, evaluates the following expressions |
Example | (unless nil "hello") |
Function Type | subr |
Arguments | anything |
Return Value | t or nil |
Description | returns t if the argument is of the class integer |
Example | (unsignedintegerp 0x0) => t |
Function Type | subr |
Arguments | none |
Return Value | nil |
Description | desactivates the tracing; from that moment on, no more messages 'enter <function name>' and 'leave <function name>' will be printed on stderr |
Example | (untrace) |
Function Type | subr |
Arguments | a mandatory string |
Return Value | t or nil |
Description | loads the optional library of which the name is given as argument; the library must be a .lsp file containing classes, methods, functions, variables and constants definitions; the .lsp file can be a bootstrap loading a shared object (ie. DLL) as a library object, and eventually also calling an initialization function of the library; the path to the .lsp file is made by concatenating the string *originpath* , "wwlisp", the option name given as argument and finally ".lsp"; the symbol *originpath* contains initially the path to the directory where the wwlisp executable came from, which is changed to the path where init.lsp came from after this one has been loaded |
Example | (use "kdialog") |
Function Type | macro |
Arguments | a list, an optional sequence of s-expr |
Return Value | returns the value of the last s-expr |
Description | evaluates the first argument and if true, evaluates the following expressions |
Example | (when t "hello") |
Function Type | expr |
Arguments | one symbol |
Return Value | a list |
Description | returns a list of all the interpreted functions, either library (ie loaded at startup) or user defined, where the symbol given as argument appears as a variable or a function name; this is the way to obtain a cross reference of a particular function |
Example | (where 'prin1) => (class-show prin1 printlist profile readerprinter-pprint savedata) |
Function Type | macro |
Arguments | a symbol, a sequence of clauses |
Return Value | nil |
Description | looks like a cond; executes each clause for which a keyword is found in the embedding function argument; the function (keyword-value), defined lexically, gives the argument following the current keyword; the macro provides for the automatic iteration in the argument list |
Example | (defun test(&rest myrest) (with-keyword-list(myrest) ('hello(print 'hello)(print(keyword-value))) ('goodbye(print 'goodbye) (print(keyword-value)) ) ) ) |