122 |
@node Reader Extensions |
@node Reader Extensions |
123 |
@subsection Reader Extensions |
@subsection Reader Extensions |
124 |
|
|
125 |
@deffn primitive read-hash-extend chr proc |
@deffn {Scheme Procedure} read-hash-extend chr proc |
126 |
|
@deffnx {C Function} scm_read_hash_extend (chr, proc) |
127 |
Install the procedure @var{proc} for reading expressions |
Install the procedure @var{proc} for reading expressions |
128 |
starting with the character sequence @code{#} and @var{chr}. |
starting with the character sequence @code{#} and @var{chr}. |
129 |
@var{proc} will be called with two arguments: the character |
@var{proc} will be called with two arguments: the character |
136 |
@section Reading Scheme Code |
@section Reading Scheme Code |
137 |
|
|
138 |
@rnindex read |
@rnindex read |
139 |
@deffn primitive read [port] |
@deffn {Scheme Procedure} read [port] |
140 |
|
@deffnx {C Function} scm_read (port) |
141 |
Read an s-expression from the input port @var{port}, or from |
Read an s-expression from the input port @var{port}, or from |
142 |
the current input port if @var{port} is not specified. |
the current input port if @var{port} is not specified. |
143 |
Any whitespace before the next token is discarded. |
Any whitespace before the next token is discarded. |
151 |
@c FIXME::martin: This is taken from libguile/options.c. Is there |
@c FIXME::martin: This is taken from libguile/options.c. Is there |
152 |
@c actually a difference between 'help and 'full? |
@c actually a difference between 'help and 'full? |
153 |
|
|
154 |
@deffn procedure read-options [setting] |
@deffn {Scheme Procedure} read-options [setting] |
155 |
Display the current settings of the read options. If @var{setting} is |
Display the current settings of the read options. If @var{setting} is |
156 |
omitted, only a short form of the current read options is printed. |
omitted, only a short form of the current read options is printed. |
157 |
Otherwise, @var{setting} should be one of the following symbols: |
Otherwise, @var{setting} should be one of the following symbols: |
163 |
@end table |
@end table |
164 |
@end deffn |
@end deffn |
165 |
|
|
166 |
@deffn procedure read-enable option-name |
@deffn {Scheme Procedure} read-enable option-name |
167 |
@deffnx procedure read-disable option-name |
@deffnx {Scheme Procedure} read-disable option-name |
168 |
@deffnx procedure read-set! option-name value |
@deffnx {Scheme Procedure} read-set! option-name value |
169 |
Modify the read options. @code{read-enable} should be used with boolean |
Modify the read options. @code{read-enable} should be used with boolean |
170 |
options and switches them on, @code{read-disable} switches them off. |
options and switches them on, @code{read-disable} switches them off. |
171 |
@code{read-set!} can be used to set an option to a specific value. |
@code{read-set!} can be used to set an option to a specific value. |
172 |
@end deffn |
@end deffn |
173 |
|
|
174 |
@deffn primitive read-options-interface [setting] |
@deffn {Scheme Procedure} read-options-interface [setting] |
175 |
|
@deffnx {C Function} scm_read_options (setting) |
176 |
Option interface for the read options. Instead of using |
Option interface for the read options. Instead of using |
177 |
this procedure directly, use the procedures @code{read-enable}, |
this procedure directly, use the procedures @code{read-enable}, |
178 |
@code{read-disable}, @code{read-set!} and @code{read-options}. |
@code{read-disable}, @code{read-set!} and @code{read-options}. |
184 |
|
|
185 |
@rnindex eval |
@rnindex eval |
186 |
@c ARGFIXME environment/environment specifier |
@c ARGFIXME environment/environment specifier |
187 |
@deffn primitive eval exp environment |
@deffn {Scheme Procedure} eval exp module |
188 |
|
@deffnx {C Function} scm_eval (exp, module) |
189 |
Evaluate @var{exp}, a list representing a Scheme expression, |
Evaluate @var{exp}, a list representing a Scheme expression, |
190 |
in the top-level environment specified by @var{environment}. |
in the top-level environment specified by @var{module}. |
191 |
While @var{exp} is evaluated (using @code{primitive-eval}), |
While @var{exp} is evaluated (using @code{primitive-eval}), |
192 |
@var{environment} is made the current module. The current module |
@var{module} is made the current module. The current module |
193 |
is reset to its previous value when @var{eval} returns. |
is reset to its previous value when @var{eval} returns. |
194 |
@end deffn |
@end deffn |
195 |
|
|
196 |
@rnindex interaction-environment |
@rnindex interaction-environment |
197 |
@deffn primitive interaction-environment |
@deffn {Scheme Procedure} interaction-environment |
198 |
|
@deffnx {C Function} scm_interaction_environment () |
199 |
Return a specifier for the environment that contains |
Return a specifier for the environment that contains |
200 |
implementation--defined bindings, typically a superset of those |
implementation--defined bindings, typically a superset of those |
201 |
listed in the report. The intent is that this procedure will |
listed in the report. The intent is that this procedure will |
203 |
evaluate expressions dynamically typed by the user. |
evaluate expressions dynamically typed by the user. |
204 |
@end deffn |
@end deffn |
205 |
|
|
206 |
@deffn primitive eval-string string |
@deffn {Scheme Procedure} eval-string string |
207 |
|
@deffnx {C Function} scm_eval_string (string) |
208 |
Evaluate @var{string} as the text representation of a Scheme |
Evaluate @var{string} as the text representation of a Scheme |
209 |
form or forms, and return whatever value they produce. |
form or forms, and return whatever value they produce. |
210 |
Evaluation takes place in the environment returned by the |
Evaluation takes place in the environment returned by the |
211 |
procedure @code{interaction-environment}. |
procedure @code{interaction-environment}. |
212 |
@end deffn |
@end deffn |
213 |
|
|
214 |
@deffn primitive apply:nconc2last lst |
@deffn {Scheme Procedure} apply:nconc2last lst |
215 |
|
@deffnx {C Function} scm_nconc2last (lst) |
216 |
Given a list (@var{arg1} @dots{} @var{args}), this function |
Given a list (@var{arg1} @dots{} @var{args}), this function |
217 |
conses the @var{arg1} @dots{} arguments onto the front of |
conses the @var{arg1} @dots{} arguments onto the front of |
218 |
@var{args}, and returns the resulting list. Note that |
@var{args}, and returns the resulting list. Note that |
223 |
@end deffn |
@end deffn |
224 |
|
|
225 |
@rnindex apply |
@rnindex apply |
226 |
@deffn primitive apply proc arg1 @dots{} args |
@deffn {Scheme Procedure} apply proc arg1 @dots{} args |
227 |
@var{proc} must be a procedure and @var{args} must be a list. Call |
@var{proc} must be a procedure and @var{args} must be a list. Call |
228 |
@var{proc} with the elements of the list @code{(append (list @var{arg1} |
@var{proc} with the elements of the list @code{(append (list @var{arg1} |
229 |
@dots{}) @var{args})} as the actual arguments. |
@dots{}) @var{args})} as the actual arguments. |
230 |
@end deffn |
@end deffn |
231 |
|
|
232 |
@deffn primitive primitive-eval exp |
@deffn {Scheme Procedure} primitive-eval exp |
233 |
|
@deffnx {C Function} scm_primitive_eval (exp) |
234 |
Evaluate @var{exp} in the top-level environment specified by |
Evaluate @var{exp} in the top-level environment specified by |
235 |
the current module. |
the current module. |
236 |
@end deffn |
@end deffn |
237 |
|
|
238 |
@deffn primitive eval2 obj env_thunk |
@deffn {Scheme Procedure} eval2 obj env_thunk |
239 |
|
@deffnx {C Function} scm_eval2 (obj, env_thunk) |
240 |
Evaluate @var{exp}, a Scheme expression, in the environment |
Evaluate @var{exp}, a Scheme expression, in the environment |
241 |
designated by @var{lookup}, a symbol-lookup function. |
designated by @var{lookup}, a symbol-lookup function. |
242 |
Do not use this version of eval, it does not play well |
Do not use this version of eval, it does not play well |
244 |
@code{primitive-eval} instead. |
@code{primitive-eval} instead. |
245 |
@end deffn |
@end deffn |
246 |
|
|
247 |
@deffn primitive read-and-eval! [port] |
@deffn {Scheme Procedure} read-and-eval! [port] |
248 |
|
@deffnx {C Function} scm_read_and_eval_x (port) |
249 |
Read a form from @var{port} (standard input by default), and evaluate it |
Read a form from @var{port} (standard input by default), and evaluate it |
250 |
(memoizing it in the process) in the top-level environment. If no data |
(memoizing it in the process) in the top-level environment. If no data |
251 |
is left to be read from @var{port}, an @code{end-of-file} error is |
is left to be read from @var{port}, an @code{end-of-file} error is |
257 |
@section Loading Scheme Code from File |
@section Loading Scheme Code from File |
258 |
|
|
259 |
@rnindex load |
@rnindex load |
260 |
@deffn procedure load filename |
@deffn {Scheme Procedure} load filename |
261 |
Load @var{filename} and evaluate its contents in the top-level |
Load @var{filename} and evaluate its contents in the top-level |
262 |
environment. The load paths are not searched. If the variable |
environment. The load paths are not searched. If the variable |
263 |
@code{%load-hook} is defined, it should be bound to a procedure that |
@code{%load-hook} is defined, it should be bound to a procedure that |
265 |
@code{%load-hook} later in this section. |
@code{%load-hook} later in this section. |
266 |
@end deffn |
@end deffn |
267 |
|
|
268 |
@deffn procedure load-from-path filename |
@deffn {Scheme Procedure} load-from-path filename |
269 |
Similar to @code{load}, but searches for @var{filename} in the load |
Similar to @code{load}, but searches for @var{filename} in the load |
270 |
paths. |
paths. |
271 |
@end deffn |
@end deffn |
272 |
|
|
273 |
@deffn primitive primitive-load filename |
@deffn {Scheme Procedure} primitive-load filename |
274 |
|
@deffnx {C Function} scm_primitive_load (filename) |
275 |
Load the file named @var{filename} and evaluate its contents in |
Load the file named @var{filename} and evaluate its contents in |
276 |
the top-level environment. The load paths are not searched; |
the top-level environment. The load paths are not searched; |
277 |
@var{filename} must either be a full pathname or be a pathname |
@var{filename} must either be a full pathname or be a pathname |
281 |
documentation for @code{%load-hook} later in this section. |
documentation for @code{%load-hook} later in this section. |
282 |
@end deffn |
@end deffn |
283 |
|
|
284 |
@deffn primitive primitive-load-path filename |
@deffn {Scheme Procedure} primitive-load-path filename |
285 |
|
@deffnx {C Function} scm_primitive_load_path (filename) |
286 |
Search @var{%load-path} for the file named @var{filename} and |
Search @var{%load-path} for the file named @var{filename} and |
287 |
load it into the top-level environment. If @var{filename} is a |
load it into the top-level environment. If @var{filename} is a |
288 |
relative pathname and is not found in the list of search paths, |
relative pathname and is not found in the list of search paths, |
289 |
an error is signalled. |
an error is signalled. |
290 |
@end deffn |
@end deffn |
291 |
|
|
292 |
@deffn primitive %search-load-path filename |
@deffn {Scheme Procedure} %search-load-path filename |
293 |
|
@deffnx {C Function} scm_sys_search_load_path (filename) |
294 |
Search @var{%load-path} for the file named @var{filename}, |
Search @var{%load-path} for the file named @var{filename}, |
295 |
which must be readable by the current user. If @var{filename} |
which must be readable by the current user. If @var{filename} |
296 |
is found in the list of paths to search or is an absolute |
is found in the list of paths to search or is an absolute |
316 |
|
|
317 |
@end defvar |
@end defvar |
318 |
|
|
319 |
@deffn primitive current-load-port |
@deffn {Scheme Procedure} current-load-port |
320 |
|
@deffnx {C Function} scm_current_load_port () |
321 |
Return the current-load-port. |
Return the current-load-port. |
322 |
The load port is used internally by @code{primitive-load}. |
The load port is used internally by @code{primitive-load}. |
323 |
@end deffn |
@end deffn |
335 |
|
|
336 |
[delay] |
[delay] |
337 |
|
|
338 |
@deffn primitive promise? obj |
@deffn {Scheme Procedure} promise? obj |
339 |
|
@deffnx {C Function} scm_promise_p (obj) |
340 |
Return true if @var{obj} is a promise, i.e. a delayed computation |
Return true if @var{obj} is a promise, i.e. a delayed computation |
341 |
(@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). |
(@pxref{Delayed evaluation,,,r5rs.info,The Revised^5 Report on Scheme}). |
342 |
@end deffn |
@end deffn |
343 |
|
|
344 |
@rnindex force |
@rnindex force |
345 |
@deffn primitive force x |
@deffn {Scheme Procedure} force x |
346 |
|
@deffnx {C Function} scm_force (x) |
347 |
If the promise @var{x} has not been computed yet, compute and |
If the promise @var{x} has not been computed yet, compute and |
348 |
return @var{x}, otherwise just return the previously computed |
return @var{x}, otherwise just return the previously computed |
349 |
value. |
value. |
355 |
|
|
356 |
[the-environment] |
[the-environment] |
357 |
|
|
358 |
@deffn primitive local-eval exp [env] |
@deffn {Scheme Procedure} local-eval exp [env] |
359 |
|
@deffnx {C Function} scm_local_eval (exp, env) |
360 |
Evaluate @var{exp} in its environment. If @var{env} is supplied, |
Evaluate @var{exp} in its environment. If @var{env} is supplied, |
361 |
it is the environment in which to evaluate @var{exp}. Otherwise, |
it is the environment in which to evaluate @var{exp}. Otherwise, |
362 |
@var{exp} must be a memoized code object (in which case, its environment |
@var{exp} must be a memoized code object (in which case, its environment |
378 |
@c FIXME::martin: This is taken from libguile/options.c. Is there |
@c FIXME::martin: This is taken from libguile/options.c. Is there |
379 |
@c actually a difference between 'help and 'full? |
@c actually a difference between 'help and 'full? |
380 |
|
|
381 |
@deffn procedure eval-options [setting] |
@deffn {Scheme Procedure} eval-options [setting] |
382 |
Display the current settings of the evaluator options. If @var{setting} |
Display the current settings of the evaluator options. If @var{setting} |
383 |
is omitted, only a short form of the current evaluator options is |
is omitted, only a short form of the current evaluator options is |
384 |
printed. Otherwise, @var{setting} should be one of the following |
printed. Otherwise, @var{setting} should be one of the following |
391 |
@end table |
@end table |
392 |
@end deffn |
@end deffn |
393 |
|
|
394 |
@deffn procedure eval-enable option-name |
@deffn {Scheme Procedure} eval-enable option-name |
395 |
@deffnx procedure eval-disable option-name |
@deffnx {Scheme Procedure} eval-disable option-name |
396 |
@deffnx procedure eval-set! option-name value |
@deffnx {Scheme Procedure} eval-set! option-name value |
397 |
Modify the evaluator options. @code{eval-enable} should be used with boolean |
Modify the evaluator options. @code{eval-enable} should be used with boolean |
398 |
options and switches them on, @code{eval-disable} switches them off. |
options and switches them on, @code{eval-disable} switches them off. |
399 |
@code{eval-set!} can be used to set an option to a specific value. |
@code{eval-set!} can be used to set an option to a specific value. |
400 |
@end deffn |
@end deffn |
401 |
|
|
402 |
@deffn primitive eval-options-interface [setting] |
@deffn {Scheme Procedure} eval-options-interface [setting] |
403 |
|
@deffnx {C Function} scm_eval_options_interface (setting) |
404 |
Option interface for the evaluation options. Instead of using |
Option interface for the evaluation options. Instead of using |
405 |
this procedure directly, use the procedures @code{eval-enable}, |
this procedure directly, use the procedures @code{eval-enable}, |
406 |
@code{eval-disable}, @code{eval-set!} and @code{eval-options}. |
@code{eval-disable}, @code{eval-set!} and @code{eval-options}. |
409 |
@c FIXME::martin: Why aren't these procedure named like the other options |
@c FIXME::martin: Why aren't these procedure named like the other options |
410 |
@c procedures? |
@c procedures? |
411 |
|
|
412 |
@deffn procedure traps [setting] |
@deffn {Scheme Procedure} traps [setting] |
413 |
Display the current settings of the evaluator traps options. If |
Display the current settings of the evaluator traps options. If |
414 |
@var{setting} is omitted, only a short form of the current evaluator |
@var{setting} is omitted, only a short form of the current evaluator |
415 |
traps options is printed. Otherwise, @var{setting} should be one of the |
traps options is printed. Otherwise, @var{setting} should be one of the |
422 |
@end table |
@end table |
423 |
@end deffn |
@end deffn |
424 |
|
|
425 |
@deffn procedure trap-enable option-name |
@deffn {Scheme Procedure} trap-enable option-name |
426 |
@deffnx procedure trap-disable option-name |
@deffnx {Scheme Procedure} trap-disable option-name |
427 |
@deffnx procedure trap-set! option-name value |
@deffnx {Scheme Procedure} trap-set! option-name value |
428 |
Modify the evaluator options. @code{trap-enable} should be used with boolean |
Modify the evaluator options. @code{trap-enable} should be used with boolean |
429 |
options and switches them on, @code{trap-disable} switches them off. |
options and switches them on, @code{trap-disable} switches them off. |
430 |
@code{trap-set!} can be used to set an option to a specific value. |
@code{trap-set!} can be used to set an option to a specific value. |
431 |
@end deffn |
@end deffn |
432 |
|
|
433 |
@deffn primitive evaluator-traps-interface [setting] |
@deffn {Scheme Procedure} evaluator-traps-interface [setting] |
434 |
|
@deffnx {C Function} scm_evaluator_traps (setting) |
435 |
Option interface for the evaluator trap options. |
Option interface for the evaluator trap options. |
436 |
@end deffn |
@end deffn |
437 |
|
|