Skip to content

clojure.core/load-file

View this page on ClojureDocs

Type: function Added: Clojure 1.0 Examples: 3 Runnable: 0
([name])

Sequentially read and evaluate the set of forms contained in the file.

Examples

by gstamp on . May have evaluation errors.
by lambder on . May have evaluation errors.
by shockbob on . May have evaluation errors.

Note by dedeibel

Be aware that this function is intended to load code only. If your data structures or a string in them grow bigger than around 65,535 it crashes.

Exception similar to:

java.lang.ClassFormatError: Unknown constant tag 49 in class file parse$eval13

Please use read-string instead.

Example:

(read-string (slurp "data.clj"))

Source: Google Groups

Note by arkh

The following marginally helpful error will be thrown if you have a typo in your file:

CompilerException java.lang.RuntimeException: Unable to resolve symbol: load-file in this context, compiling:(NO_SOURCE_PATH:1:1)

Fix the syntax error(s) in and you'll be able to use load-file again.

See also


Content from the matching ClojureDocs page, with authors credited on each contribution.