Skip to content

Latest commit

 

History

History
317 lines (212 loc) · 12.7 KB

scml_base_control.md

File metadata and controls

317 lines (212 loc) · 12.7 KB

Module scml_base_control

Scheme base library for control features

. __Authors:__ Joseph Wayne Norton ([`[email protected]`](mailto:[email protected])).

Function Index

'$scml_exports'/0
'call-with-values'/5

Calls its producer argument with no values and a continuation that, when passed some values, calls the consumer procedure with those values as arguments. The continuation for the call to consumer is the continuation of the call to call-with-values.

.
'call/cc'/4

Packages the current continuation as an "escape procedure" and passes it as an argument to Proc. The escape procedure is a Scheme procedure that, if it is later called, will abandon whatever continuation is in effect at that later time and will instead use the continuation that was in effect when the escape procedure was created. Calling the escape procedure will cause the invocation of before and after thunks installed using dynamic-wind.

.
'dynamic-wind'/6

Calls Thunk without arguments, returning the result(s) of this call. Before and After are called, also without arguments, as required. Note that, in the absence of calls to continuations captured using call/cc, the three arguments are called once each, in order.Before is called whenever execution enters the dynamic extent of the call to Thunk and After is called whenever it exits that dynamic extent. The Before and After thunks are called in the same dynamic environment as the call to dynamic-wind.

No special handling is given for escapes that might occur inside
the +Before+ and +After+ thunks. It protects the +Thunk+ by its
continuation that enforces the following three rules.
  1. Its normal continuation is for Before to be called before Thunk, which is called before After, and finally to return the value of the evaluation of Thunk as the value of the entire dynamic-wind expression.

  2. If an escape is made out of the Thunk, dynamic-wind guarantees that the After will be called before the escape occurs.

  3. If an escape is made into the Thunk, it guarantees that the Before will be called before control is returned to the place of initial escape in the Thunk, and finally the After is called.

.
'for-each'/4

Applies proc element-wise to the elements of the lists and returns #f. Calls proc for its side effects rather than for its values. Unlike map, for-each is guaranteed to call proc on the elements of the lists in order from the first element(s) to the last. If more than one list is given and not all lists have the same length, for-each terminates when the shortest list runs out.

.
'procedure?'/1

Returns #t if obj is a procedure, otherwise returns #f.

.
'string-for-each'/4Equivalent to 'for-each'([Proc | Args]).
'string-map'/4Equivalent to map([Proc | Args]).
'vector-for-each'/4Equivalent to 'for-each'([Proc | Args]).
'vector-map'/4Equivalent to map([Proc | Args]).
apply/4

Calls Proc with the elements of the list (append (list arg1 \.\.\.) args) as the actual arguments.

.
map/4

Applies proc element-wise to the elements of the lists and returns a list of the results, in order. If more than one list is given and not all lists have the same length, map terminates when the shortest list runs out. The dynamic order in which proc is applied to the elements of the lists is unspecified.

.
values/4

Delivers all of its arguments to its continuation.

.

Function Details

'$scml_exports'/0


'$scml_exports'() -> [{scm_symbol(), scmi_nip()}]



'call-with-values'/5


'call-with-values'(Producer::scm_thunk(), Consumer::scm_proc(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_any()



Calls its producer argument with no values and a continuation that, when passed some values, calls the consumer procedure with those values as arguments. The continuation for the call to consumer is the continuation of the call to call-with-values.

'call/cc'/4


'call/cc'(Proc::scm_proc(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_any()



Equivalent to 'call-with-current-continuation(Proc)'.

Packages the current continuation as an "escape procedure" and passes it as an argument to Proc. The escape procedure is a Scheme procedure that, if it is later called, will abandon whatever continuation is in effect at that later time and will instead use the continuation that was in effect when the escape procedure was created. Calling the escape procedure will cause the invocation of before and after thunks installed using dynamic-wind.

'dynamic-wind'/6


'dynamic-wind'(Before::scm_thunk(), Thunk::scm_thunk(), After::scm_thunk(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_any()



Calls Thunk without arguments, returning the result(s) of this call. Before and After are called, also without arguments, as required. Note that, in the absence of calls to continuations captured using call/cc, the three arguments are called once each, in order.Before is called whenever execution enters the dynamic extent of the call to Thunk and After is called whenever it exits that dynamic extent. The Before and After thunks are called in the same dynamic environment as the call to dynamic-wind.

No special handling is given for escapes that might occur inside
the +Before+ and +After+ thunks. It protects the +Thunk+ by its
continuation that enforces the following three rules.
  1. Its normal continuation is for Before to be called before Thunk, which is called before After, and finally to return the value of the evaluation of Thunk as the value of the entire dynamic-wind expression.

  2. If an escape is made out of the Thunk, dynamic-wind guarantees that the After will be called before the escape occurs.

  3. If an escape is made into the Thunk, it guarantees that the Before will be called before control is returned to the place of initial escape in the Thunk, and finally the After is called.

'for-each'/4


'for-each'(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_false()



Applies proc element-wise to the elements of the lists and returns #f. Calls proc for its side effects rather than for its values. Unlike map, for-each is guaranteed to call proc on the elements of the lists in order from the first element(s) to the last. If more than one list is given and not all lists have the same length, for-each terminates when the shortest list runs out.

'procedure?'/1


'procedure?'(Exp::scm_obj()) -> scm_boolean()



Returns #t if obj is a procedure, otherwise returns #f.

'string-for-each'/4


'string-for-each'(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_false()



Equivalent to 'for-each'([Proc | Args]).

'string-map'/4


'string-map'(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_string()



Equivalent to map([Proc | Args]).

'vector-for-each'/4


'vector-for-each'(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_false()



Equivalent to 'for-each'([Proc | Args]).

'vector-map'/4


'vector-map'(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_vector()



Equivalent to map([Proc | Args]).

apply/4


apply(Arg::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_any()



Calls Proc with the elements of the list (append (list arg1 \.\.\.) args) as the actual arguments.

map/4


map(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> [scm_any()]



Applies proc element-wise to the elements of the lists and returns a list of the results, in order. If more than one list is given and not all lists have the same length, map terminates when the shortest list runs out. The dynamic order in which proc is applied to the elements of the lists is unspecified.

values/4


values(Args::[scm_any(), ...], Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_any()



Delivers all of its arguments to its continuation.