REDUCE

10.7 Reading Files into PSL

The following procedures are used to read complete files into PSL, by first calling open, and then processing each top level form in the file. The effect is similar to what would happen if the file were typed into PSL. File names are represented by strings. File names may be given using full system dependent file name conventions.

*echo = [Initially: nil] switch
   
The switch echo is used to control the echoing of input. When (on echo) is placed in an input file, the contents of the file are echoed on the standard output device. Dskin does not change the value of *echo, so one may say (on echo) before calling dskin, and the input will be echoed.

(dskin NAME:string): nil, abort expr
The contents of the file are processed as if they were typed in. If the processing of the file is aborted the return value will be the identifier abort and the following error message will be printed.

⋆⋆⋆⋆⋆ DSKIN of ‘NAME' aborted after N form(s)

A count of each top level form is kept as they are processed, which is the value N in the error message. Once in* has been bound to the channel which represents the open file, each form is processed by a function similar to the one below.

  (de dskin-step ()  
    (let ((form (funcall toploopread⋆)))  
      (cond ((eq form $eof$) 'eof)  
            ((not ⋆defn)  
             (funcall toploopprint⋆ (funcall toploopeval⋆ form))  
            (dfprint⋆ (funcall dfprint⋆ form))  
            (t (prettyprint form)))))

Note that the functions used for reading, evaluating and printing are the same as those used in toploop (see Chapter 15 for more information). If dfprint* has a value (and the switch *defn is non-nil), then it will be applied to the expression instead of applying the functions bound to toploopeval* and toploopprint*. If dfprint* does not have a value (and the switch *defn is nil), then the expression will be simply be printed by a call on prettyprint.

Dskin is flagged ignore. This means that when a file is compiled, a top level application of dskin will be evaluated but not compiled. For more information about the flag ignore see Chapter 19.

(lapin NAME:string): {nil, abort} expr
Almost identical to dskin. The difference is that the function bound to toploopprint* is not applied. In general, this means that the results of evaluation are not printed.

Note that lapin is not flagged ignore as is dskin. This means that a top level application of lapin is compiled but not evaluated. For more information on how the flags ignore and eval effect compilation see Chapter 19.

(faslin FILENAME:string): nil expr
This is an efficient binary read loop, which fetches blocks of code, constants and compactly stored ids. It uses a bit-table to relocate code and to identify special LISP-oriented constructs. FILENAME must be a complete file name.