Next: , Previous: , Up: The Language   [Contents][Index]

4.7 Eval and Load

Function: try-load filename

If the string filename names an existing file, the try-load procedure reads Scheme source code expressions and definitions from the file and evaluates them sequentially and returns #t. If not, try-load returns #f. The try-load procedure does not affect the values returned by current-input-port and current-output-port.

Variable: *load-pathname*

Is set to the pathname given as argument to load, try-load, and dyn:link (see Compiling And Linking in Hobbit). *load-pathname* is used to compute the value of program-vicinity in SLIB.

Function: eval obj

Alias for eval in SLIB.

Function: eval-string str

Returns the result of reading an expression from str and evaluating it. eval-string does not change *load-pathname* or line-number.

Function: load-string str

Reads and evaluates all the expressions from str. As with load, the value returned is unspecified. load-string does not change *load-pathname* or line-number.

Function: line-number

Returns the current line number of the file currently being loaded.


Previous: , Up: Eval and Load   [Contents][Index]

4.7.1 Line Numbers

Scheme code defined by load may optionally contain line number information. Currently this information is used only for reporting expansion time errors, but in the future run-time error messages may also include line number information.

Function: try-load pathname reader

This is the primitive for loading, pathname is the name of a file containing Scheme code, and optional argument reader is a function of one argument, a port. reader should read and return Scheme code as list structure. The default value is read, which is used if reader is not supplied or is false.

Line number objects are disjoint from integers or other Scheme types. When evaluated or loaded as Scheme code, an s-expression containing a line-number in the car is equivalent to the cdr of the s-expression. A pair consisting of a line-number in the car and a vector in the cdr is equivalent to the vector. The meaning of s-expressions with line-numbers in other positions is undefined.

Function: read-numbered port

Behaves like read, except that

  • bullet Load (read) sytnaxes are enabled.
  • bullet every s-expression read will be replaced with a cons of a line-number object and the sexp actually read. This replacement is done only if port is a tracked port See See Files and Ports.
Function: integer->line-number int

Returns a line-number object with value int. int should be an exact non-negative integer.

Function: line-number->integer linum

Returns the value of line-number object linum as an integer.

Function: line-number? obj

Returns true if and only if obj is a line-number object.

Function: read-for-load port

Behaves like read, except that load syntaxes are enabled.

Variable: *load-reader*
Variable: *slib-load-reader*

The value of *load-reader* should be a value acceptable as the second argument to try-load (note that #f is acceptable). This value will be used to read code during calls to scm:load. The value of *slib-load-reader* will similarly be used during calls to slib:load and require.

In order to disable all line-numbering, it is sufficient to set! *load-reader* and *slib-load-reader* to #f.


Next: , Previous: , Up: The Language   [Contents][Index]