Interpretation of file name

On procedures which takes file name as argument and carries out inout/output on it, the following interpretation is done to the string given as file name.
"pathname" First element is character other than #\< #\> #\|
Treat entire string as a path name of file. If a file with the given name already exists on output procedure, the result is unspecified.
"<pathname" First element is #\<
Valid on input procedure. Treat susbstring starting from the second character as a path name of file.
">pathname" First element is #\> and second is not #\>
Valid on output procedure. Treat substring starting from the second character as a path name of file. If a file with the given name already exists, overwrite it.
">>pathname" First element is #\> and second is #\>
Valid on output procedure. Treat substring starting from the third character as a path name of file. If a file with the given name already exists, append to it.
"|command" Frist element is #\|
Treat substring starting from the second character as a command string. On input procedure, resulting port inputs from its standard output. On output procedure, resulting port outputs to its standard input. Exit status can be retrieved by rp:file-status (see below.)

Because whether the string is for input or for output is determined by the procedure it is supplied for, pipe symbol is always put on the head. Notice that the syntax is different from that in perl in this point.

General

(gensym) procedure
Generates (uninterned) symbol.
(rp:symbol-value symbol) procedure
Value of symbol (in the toplevel environment.) This is intended to be used to implement features such as property list seen in other lisp dialects. Mixing the usage of symbol as a variable on program and the usage of rp:symbol-value is discouraged.
(rp:symbol-value-set! symbol value) procedure
Set value of symbol (in the toplevel environment.) See note on rp:symbol-value.
(rp:symbol-bound? symbol) procedure
Returns #t if symbol is bound in the toplevel environment, otherwise returns #f.
(eval expression) procedure
Evaluate expression in toplevel environment.
(break [prompt]) procedure
Execute read-eval-print loop. Prompt is given as string. If it is not supplied, defaults to "break> ".
(continue) procedure
Exit from innermost break loop. In normal toplevel, this means the end of pi. The variable continue is unbound if break loop is not executing.

Macros

(rp:eval-in-compiler-environment expression) syntax
On interpreter, expression is simply evaluated. Put in toplevel, expression will be evaluated at compile time, leaving its side effects to compilation process.
(rp:load-into-compiler-environment file) syntax
Have same effect with (load file) on interpreter. Put in toplevel, file will be loaded to the environment of compiler when compiled. So the content of the file will affect the compilation process insted of included in the output code.

System environment

(exit [exit-code]) procedure
Exit pi with exit-code as status. Default of exit-code is 0.
(system string) procedure
Execute system() in the standard library and returns its vaule.
(getenv string) procedure
Vaule of environment variable string.
(file-exists? string) procedure
Returns #t if a file with name string exists, #f otherwise.
*invocation-arg* global variable
List consists with program name and its arguments.
(rp:command-line-arguments) procedure
Vector of command line arguments.
(rp:time) procedure
Information of execution time of process in the form #(real user sys).
(rp:errno) procedure
Value of errno in the standard library.
(rp:strerror errono) procedure
String retrieved by calling strerror(errno) in standard library.

Errors

(error [error-code]) procedure
Cause an error.
(rp:catch-error procedure expression) syntax
Catch errors.
First, evaluate procedure. The result must be a procedure with one argument. Next, evaluate expression and return its vaule. If error is caused in evaluating expression, procedure is called in the form
	(procedure error-code)
and the vaule will be the value of entire form. The error processing environment consists a part of continuation.
(rp:call-with-error-handler error-proc thunk) procedure
(rp:catch-error procedure expression) is implemented as a macro expanded to the following.
	(rp:call-with-error-handler error-proc (lambda () expression))
(rp:error-message error-code) procedure
Returns error message as a string.
(rp:print-error-message error-code [port]) procedure
Outputs error message to port (default is current-output-port.)

Signals

(rp:set-signal-handler signal procedure) procedure
Signal is a signal numberd by system, procedure is a procedure with one argument or #t or #f. If signal is raised, procedure is called as
	(procedure signal)
No particular restriction is imposed on the behavior of this procedure. If procedure is #t, the default action is restored. If procedure is #f, signal will be ignored. Vaule is the previous signal handler.
(rp:signal-message signal) procedure
Returns signal message as a string.
(rp:print-signal-message signal [port]) procedure
Output signal message to port (default is current-output-port.)

7. Ports

(rp:current-error-port) procedure
Returns the output port which corresponds to stderr.
(rp:set-current-input-port [port]) procedure
(rp:set-current-output-port [port]) procedure
Changes current-input-port, current-output-port respectively. If the argument is omitted, the original one at invocation is restored.
(open-input-string string) procedure
Returns input port which takes input from string.
(open-output-string) procedure
Returns output port which writes to string.
(get-output-string port) procedure
Port must be a output port made by rp:open-output-string. Retrieves string consisting of characters outputted to the port so far.
(rp:open-input-procedure procs) procedure
Returns input port. Procs is a vector with four elements, say
	#(getchar ungetchar getlinecount char-readyp)
Each element is a procedure. Doing a input from resulting port causes invocation of getchar.
  	(getchar) => (char . procs')
procs' is a vector simillar to procs (simillar in the following,) say
  	#(getchar' ungetchar' getlinecount' char-readyp')
If char is a character, it will be a charecter read from the port. If char is a number, input lasts with a error and the number will be its error code. If char is #f, port is effectively in a end-of-file status. In the next usage of port, procs' will be used.
Ungetchar gets called as
  	(ungetchar char) => procs'
Here, (getchar') => (char . procs''), procs == procs'' is expected.
Getlinecount gets called as
	(getlinecount) => (linecount . procs')
linecount is a integer, treated as a line number when getlinecount is called. In particular, if it was 0, it means the line number is not applicable.
Char-readyp gets called as
  	(char-readyp) => (ready? . procs')
If ready? is a Boolean value, it will be a vaule of char-ready? of that port. If it is a number, error is caused with that error number.

Note: In the duration of execution of these procedures, the port will be unusable. So, in particular, errors should not be generated. Errorneous conditions should be reported to the mechanism which calls the procedure via the interface above. The effect is unpreditable if an instance of invocation of these procedures returns multiple times.

(rp:open-output-procedure proc) procedure
Returns output port. Proc is a procedure. Doing a output to resulting port causes invocation of proc in the form
	(proc char) => (result . proc')
Char is a character to be outputted. If result is #t, the output is assumed to be done normally. If result is a number, error will be generated with the error number. In the next usage of port, proc' will be used. The same note is applied as rp:open-output-procedure.
(rp:file-status port) procedure
Port must be a port result from open-output-file or open-input-file. The following vaules are returned accroding to the status of port at closing time.
#f Port is not closed yet.
Generates a error Underlying close operation (flose or pclose) returned -1.
Integer vaule Return vaule other than -1 of underlying close operation (fclose of pclose.)

Debugger support

(rp:apply-with-evaluator-hook hook-function procedure arguments)
(rp:hook-evaluator hook-function expression environment continuation)
(rp:call-evaluator expression environment)
(rp:top-level-environment)
(rp:expression->data expression environment)
(rp:hook-applicator hook-function procedure)
(rp:unhook-applicator procedure)
Dateiled descriptions of these procedures will not be given here. If you are interested, cunsult to the implementation of step, trace and such in debugger.pi. The auther may write individual document in the future.

indexes