Operation Map - urschleim/scream GitHub Wiki
Symbol Reference
Spec | r7rs chapter page |
---|
a
apply
Spec | r7rs 6.10 p50 |
---|---|
Implementation: | procedure.s |
(apply proc args1 ... args)
b
c
d
define
Spec | r7rs 5.3 Variable definitions p25 |
---|---|
Implementation: | pops/SyntaxDefine.java |
(define variable expression) ; syntax
Binds the value of expression to a new variable in the current environment. If the variable is already bound, then it is rebound to the new value.
Notes
Note that the variable is bound in the current environment. If a variable is bound for example in a (let ...)
body, then it is visible inside the body but is not longer visible if the body terminates. In other words, the variable is not bound automatically in the interaction environment.
Example
donaldduck
⇒ Error: donaldduck not defined
(define donaldduck 'unca)
⇒ () No error
donaldduck
⇒ 'unca
(let ((message "number plate: "))
; Creates a binding in the current environment opened by let.
(define donaldduck 313)
(display message)
(display donaldduck)
(newline)
donaldduck)
⇒ stdout: "number plate: 313"
⇒ 313
; let terminated, we're back in the interaction environment.
; In this context the value did not change.
donaldduck
⇒ unca
display
Spec | r7rs 6.13.3 Output p59 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/i-ports-output.s et al. |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_13_3_Output_Test.java |
(display obj) ; procedure
(display obj port) ; procedure
Write obj to the passed port. If no port is passed then writes to (current-output-port)
.
Fully implemented.
Note
(display ...)
is intended for producing human-readable (vs. machine-readable ) output.- No newline is added, to add it use
(newline)
.
Example
(display "Donald Duck")
⇒ stdout: Donald Duck ; No double quotes for humans.
⇒ () No error
e
error
Spec | r7rs 6.11 Exceptions p54 |
---|---|
Implementation: | /scream/src/main/java/de/michab/scream/pops/Exceptions_6_11.java |
Tests: | /scream/src/test/java/de/michab/scream/RaiseTest.java, RuntimeXTest.java |
language/R7rs_6_11_Exceptions_Test.java` |
(error message obj) ; procedure
The message argument must be a string. If this string contains a colon ':' then it is split, both sides are trimmed and the left side of the colon is interpreted as the name of the operation that called `(error ...). The remaining right part is then the message.
(error "null-list?: argument out of domain" 1)
⇒ stderr: ERROR : null-list? : argument out of domain 1
A list of error codes exist that can be used as the message text.
Code | Description |
---|---|
INTERNAL_ERROR, | An internal error occurred. |
NOT_IMPLEMENTED, | |
SYMBOL_NOT_DEFINED, | |
SYMBOL_NOT_ASSIGNABLE, | |
TOO_MANY_SUBEXPRESSIONS, | |
SYNTAX_ERROR, | |
DEFINE_ERROR, | |
EXPECTED_PROPER_LIST, | |
INDEX_OUT_OF_BOUNDS, | |
CALLED_NON_PROCEDURAL, | |
INVALID_ASSOC_LIST, | |
CAR_FAILED, | |
TYPE_ERROR, | |
NOT_ENOUGH_ARGUMENTS, | |
TOO_MANY_ARGUMENTS, | |
WRONG_NUMBER_OF_ARGUMENTS, | |
REQUIRES_EQUIVALENT_CONS_LEN, | |
BAD_BINDING, | |
BAD_CLAUSE, | |
DIVISION_BY_ZERO, | |
PORT_CLOSED, | |
EXPECTED_INPUT_PORT, | |
EXPECTED_OUTPUT_PORT, | |
IO_ERROR, | |
DUPLICATE_FORMAL, | |
INVALID_FORMALS, | |
CLASS_NOT_FOUND, | |
FIELD_NOT_FOUND, | |
METHOD_NOT_FOUND, | |
ILLEGAL_ACCESS, | |
INVOCATION_EXCEPTION, | |
CANNOT_ACCESS_INSTANCE, | |
CREATION_FAILED, | |
ILLEGAL_ARGUMENT, | |
SCAN_UNBALANCED_QUOTE, | |
SCAN_UNEXPECTED_CHAR, | |
ERROR, | |
PARSE_EXPECTED, | |
PARSE_UNEXPECTED_EOF, | |
PARSE_UNEXPECTED, | |
INTERRUPTED, | |
CANNOT_MODIFY_CONSTANT, | |
NO_PROXY, | |
PROXY_CANNOT_INSTANTIATE, | |
ONLY_IN_QUASIQUOTE_CONTEXT, | |
RADIX_NOT_SUPPORTED, | |
DUPLICATE_ELEMENT, | |
EXPECTED_BINARY_PORT, | |
EXPECTED_TEXTUAL_PORT, | |
SCAN_UNBALANCED_COMMENT, | |
RANGE_EXCEEDED |
f
flush-output-port
Spec | r7rs 6.13.3 p59 |
---|
(flush-output-port)
(flush-output-port port)
Flush an output port.
g
h
i
j
k
l
list-copy
Spec | r7rs 6.4 Pairs and lists p34 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/6_4_Pairs_and_lists.s et al. |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_4_PairsLists_Test.java |
(list-set! list k obj) ; procedure
Store obj in the kth element of list.
Fully implemented.
Note
- The passed list must be a list in the sense of
list?
.
Example
(let ((ls (list 'one 'two 'five!)))
(list-set! ls 2 'three)
ls)
⇒ (one two three)
list-set!
Spec | r7rs 6.4 Pairs and lists p43 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/6_4_Pairs_and_lists.s et al. |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_4_PairsLists_Test.java |
(list-set! list k obj) ; procedure
Store obj in the kth element of list.
Fully implemented.
Note
- The passed list must be a list in the sense of
list?
.
Example
(let ((ls (list 'one 'two 'five!)))
(list-set! ls 2 'three)
ls)
⇒ (one two three)
m
map
Spec | r7rs 6.10 Control features p51 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/6_10_Control_features.s |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_10_Control_features_Test.java |
(map proc list₁ list₂ ...) ; procedure
Applies proc element-wise to slices of the passed lists and returns a list of the results.
Note
Fully implemented.
Example
(map + '(1 2 3) '(4 5 6 7))
⇒ (5 7 9)
n
o
p
q
r
raise
Spec | r7rs 6.11 p54 |
---|---|
Implementation: | /scream/src/main/java/de/michab/scream/pops/R7RsExceptions_6_11.java |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_11_Exceptions_Test.java |
(raise obj) procedure
Raises an exception by invoking the current exception handler installed by (with-exception-handler jandler thunk)
.
Fully implemented.
raise-continuable
Spec | r7rs 6.11 p54 |
---|---|
Implementation: | /scream/src/main/java/de/michab/scream/pops/R7RsExceptions_6_11.java |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_11_Exceptions_Test.java |
(raise obj) procedure
Raises a continuable exception by invoking the current exception handler installed by (with-exception-handler jandler thunk)
.
The result of the invoked thunk will be returned by the call of (raise-continuable obj)
.
Fully implemented.
s
set!
Spec | r7rs 4.1.6 p14 |
---|---|
Implementation: | SyntaxAssign.java |
(set! symbol value)
Binds an existing symbol to a new value.
Notes
The symbol has to exist, if it does not exist this is an error.
Example
donaldduck
⇒ Error: donaldduck not defined
(set! donaldduck 313)
⇒ Error donaldduck not defined
(define donaldduck 'unca)
⇒ () No error
donaldduck
⇒ unca
(set! donaldduck 313)
⇒ () No error
donaldduck
⇒ 313
string-map
Spec | r7rs 6.10 Control features p51 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/6_10_Control_features.s |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_10_Control_features_Test.java |
(string-map proc string₁ string₂ ...) ; procedure
Applies proc element-wise to slices of the passed string and returns a string of the results characters.
proc
needs to be a procedure of the form (proc char ...) ⇒ char
, where the number of characters passed
has to correspond to the numbers of strings passed to string-map
.
Note
Fully implemented.
Example
(string-map char-upcase "donald")
⇒ "DONALD"
t
u
v
values
Spec | r7rs 6.10 p53 |
---|
(values obj ...)
Delivers all its arguments to its continuation.
Notes
None.
Example
To be done.
vector-map
Spec | r7rs 6.10 Control features p51 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/6_10_control_features.s |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_10_Control_features_Test.java |
(vector-map proc vector₁ vector₂ ...) ; procedure
Applies proc element-wise to slices of the passed vectors and returns a vector of the results.
Fully implemented.
Example
(vector-map + '#(1 2 3) '#(4 5 6 7))
⇒ #(5 7 9)
w
with-exception-handler
Spec | r7rs 6.11 p54 |
---|---|
Implementation: | /scream/src/main/java/de/michab/scream/pops/R7RsExceptions_6_11.java |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_11_Exceptions_Test.java |
(with-exception-handler handler thunk) procedure
Adds an exception handler that handles calls of (raise obj)
in the thunk.
Fully implemented.
write
Spec | r7rs 6.13.3 Output p58 |
---|---|
Implementation: | /scream/src/main/resources/de/michab/scream/extensions/i-ports-output.s et al. |
Tests: | /scream/src/test/java/de/michab/scream/language/R7rs_6_13_3_Output_Test.java |
(write obj) ; procedure
(write obj port) ; procedure
Write obj to the passed port. If no port is passed then writes to (current-output-port)
.
Fully implemented.
Note
(write ...)
is intended for producing machine-readable (vs. human-readable ) output. The operation does not flush the written data.
Example
(write "Donald Duck")
⇒ stdout: No output since data is buffered.
⇒ () No error
(flush-output-port)
⇒ stdout: "Donald Duck" ; Including the double quotes, remember *data* is written.
⇒ () No error
write-bytevector
Spec | r7rs 6.13.3 p59 |
---|
(write-bytevector bytevector) ; NOT supported
(write-bytevector bytevector port)
(write-bytevector bytevector port start)
(write-bytevector bytevector port start end)
Write a bytevector to a binary stream.
Notes
The signature using the default stream is skipped since the default stream is a textual stream.
Example
; Make a bytevector.
(define bv #u8(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
; Create the in-memory port to write.
(define obv (open-output-bytevector))
; Write two bytes.
(write-bytevector bv obv 10 12)
; Check what was written.
(get-output-bytevector obv) ; => #u8(#x0a #x0b)
; Close in-memory-port.
(close-port obv)
x
y
z
r7rs
4.2.9 Case-lambda
Research:
6.3 Booleans
Fully supported.
(boolean=?)
boolean.s
6.10 Control features
(apply proc arg1 ... args)
procedure.s
6.12 Environments and evaluation
(scheme-report-environment)
i-environment.s
(null-environment)
i-environment.s
(interaction-environment)
i-environment.s
(eval expr-or-def environment-specifier)
Scream.java
6.13 Input and output
6.13.1 Ports
(current-input-port)
i-ports.s
(current-output-port)
i-ports.s
(current-error-port)
i-ports.s
scream extensions
scream:eval
Evaluates an expression in the current dynamic environment. Implemented in ScreamEvaluator.
scream:evaluator
Object reference to the current SchemeEvaluator
.
Defined and initialized in the SchemeEvaluator implementation.
scream:type-bool
Typename of boolean values. Defined in boolean.s
(typePredicateGenerator string-type-name exact-match)
Is used to generate most of the type predicate procedures like vector?, char?, etc. in the system.
(describe-object)
Procedure in SchemeObject.java
evaluate
Procedure in Environment.java
if
Syntax in Syntax.java
load
Implemented in 'instance-init.s'. Maps to SchemeEvaluator2#load
.
make-object
Syntax in SchemeObject.java
object
Procedure in SchemeObject.java
object?
Procedure in SchemeObject.java
scream::evaluator
A reference to the evaluator instance that is mapped as a SchemeObject and references the ScreamEvaluator implementing the ScriptEngine base class.
%%errOut%%
%error-id
%catch
Syntax in SchemeObject.java
%error-object
/ (divide)
Procedure in Number.java