source: project/wiki/man/5/TODO/Unit eval @ 34256

Last change on this file since 34256 was 34256, checked in by sjamaan, 11 months ago

man/5: Move docs on provide and require to Module (chicken load)

File size: 1.3 KB
Line 
1[[tags: manual]]
2[[toc:]]
3
4== Unit eval
5
6This unit has support for evaluation and macro-handling. This unit is used
7by default, unless the program is compiled with the {{-explicit-use}}
8option.
9
10=== Loading code
11
12==== load
13
14<procedure>(load FILE [EVALPROC])</procedure>
15
16Loads and evaluates expressions from the given source file, which may be either
17a string or an input port. Each expression read is passed to {{EVALPROC}}
18(which defaults to {{eval}}). On platforms that support it (currently BSD,
19Haiku, MacOS X, Linux, Solaris, and Windows), {{load}} can be used to load
20compiled programs:
21
22 % cat x.scm
23 (define (hello) (print "Hello!"))
24 % csc -s x.scm
25 % csi -q
26 #;1> (load "x.so")
27 ; loading x.so ...
28 #;2> (hello)
29 Hello!
30 #;3>
31
32The second argument to {{load}} is ignored when loading compiled
33code.
34If source code is loaded from a port, then that port is closed after
35all expressions have been read.
36
37A compiled file can only be loaded once. Subsequent attempts to load the
38same file have no effect.
39
40=== Eval
41
42==== eval
43
44<procedure>(eval EXP [ENVIRONMENT])</procedure>
45
46Evaluates {{EXP}} and returns the result of the evaluation. The second argument is optional
47and defaults to the value of {{(interaction-environment)}}.
48
49
50---
51Previous: [[Unit library]]
52
53Next: [[Unit repl]]
Note: See TracBrowser for help on using the repository browser.