- Read syntax: #+ <feature> <form>
-
If <feature> is
provided?
then <form> is read as a scheme expression. If not,
then <form> is treated as whitespace.
<feature> is a boolean expression composed of symbols
and and, or, and not of boolean
expressions.
For more information on provided?,
See section `Feature' in SLIB.
- Read syntax: #- <feature> form
-
is equivalent to
#+(not <feature>) form.
There are times where the Schlep-Dialect is not completely portable to
all target languages. #+ and #- can be used
to conditionalize code so that one source file is still sufficient.
All Schlep translators provide the SCHLEP feature. And
each translator provides its name
(SCM2JAVA, SCM2CS, or SCM2C) as
a feature.
So #+(or SCM2JAVA SCM2CS SCM2C) is
equivalent to #+SCHLEP.
- Syntax: quote <datum>
-
Quoted symbols are translated into strings with the
target-language-specific substitutions. Giving a quoted procedure
name as an argument to
dprintf, wdprintf,
or edprintf has the correct function name appearing in
the message. The `%s' format in the SLIB implementation
of printf accepts either strings or symbols.
- Syntax: and <test1> ...
-
- Syntax: or <test1> ...
-
- Syntax: set! <identifier> <expression>
-
- Syntax: if <test> <consequent> <alternate>
- Syntax: if <test> <consequent>
-
- Syntax: cond <clause1> <clause2> ...
-
- Syntax: case <key> <clause1> <clause2> ...
- Syntax: qase <key> <clause1> <clause2> ...
-
Treated the same. Valid only in a tail position or if its return
value is ignored.
- Syntax: begin <expression1> <expression2> ...
-
- Syntax: lambda <formals> <body>
-
lambda is supported only as the argument
to call-with-current-continuation,
and in the function position of a form, for example:
((lambda (x) (+ 1 x)) k).
- Syntax: let <bindings> <body>
- Syntax: let* <bindings> <body>
- Syntax: letrec <bindings> <body>
-
The expression must either be in the tail-position or its value must
be ignored. These are all treated as
letrec*. Java does
not allow nested identifier reuse
like (let ((foo 5)) (let ((foo 99)) foo));
so the difference between let* and let for
non-procedure bindings is not exposed. Mutually recursive internal
procedures are also not supported, so there is no difference
between letrec* and letrec for procedure
bindings.
- Syntax: let <variable> <bindings> <body>
-
Named
let.
- Syntax: do <bindings> <clause> <body>
-
- Syntax: define <identifier> <expression>
- Syntax: defvar <identifier> <expression>
-
Is a variable declaration.
- Syntax: define <identifier> (lambda <formals> <expression>)
- Syntax: define (<identifier> <formals>) <body>
-
Defines a top-level or internal procedure.
Tail recursion is preserved for procedures tail calling themselves and
for procedures defined using internal define. Mutual
tail recursion is not preserved. Internal procedures called in
non-tail position are not supported.
- Syntax: defconst <identifier> <expression>
-
Becomes a
#define in C; readonly in
C#; final in Java.
- Syntax: defmacro <identifier> (<formals>) <body>
- Syntax: defmacro (<identifier> <formals>) <body>
-
Invocations of
defmacros are expanded before translation
to the target language.
These are the Scheme and SLIB procedures getting
special treatment by the translators.
- Function: call-with-current-continuation (lambda (<identifier>) <body>)
-
Escape continuations only.
- Procedure: load filename
- Procedure: require 'feature
-
Ignored.
- Procedure: provide 'feature
-
Does not get translated; but adds feature to the set of
features such
that
#+feature expression will
incorporate expression where it occurs.
- Function: not obj
-
Logical inversion (not bitwise).
- Function: ceiling x1
- Function: floor x1
- Function: inexact->exact x1
- Function: * x1 ...
- Function: + x1 ...
- Function: - x1 x2 ...
- Function: / x1 x2 ...
- Function: quotient n1 n2
-
Translate to the native operators.
- Function: modulo n1 n2
- Function: remainder n1 n2
-
Both are translated to n1
% n2.
- Function: max n1 n2
- Function: max x1 x2
- Function: min n1 n2
- Function: min x1 x2
-
Native operators. Some C implementations may implement as:
#define max(a,b) ((a)<(b)?(b):(a))
#define min(a,b) ((a)>(b)?(b):(a))
which will evaluate a or b twice.
- Function: = x1 x2
- Function: eq? obj1 obj2
- Function: eqv? obj1 obj2
- Function: char=? char1 char2
-
Are all translated to `=='.
- Function: < x1 x2
- Function: <= x1 x2
- Function: >= x1 x2
- Function: > x1 x2
- Function: negative? x
- Function: zero? x
- Function: positive? x
- Function: char<? char1 char2
- Function: char<=? char1 char2
- Function: char>=? char1 char2
- Function: char>? char1 char2
-
- Function: odd? n
- Function: even? n
-
- Function: number? obj
-
Always returns true.
- Function: char-downcase char
- Function: char-upcase char
-
- Function: char->integer char
- Function: integer->char k
-
- Function: string->number string
-
Integers only.
- Function: atoll string
-
64-bit integer.
- Function: atof string
-
Double precision floating-point.
- Function: number->string n k
-
Java calls
integerToString;
C# calls Convert.ToString;
C calls integer_to_string.
- Function: number->string x
-
Java calls
numberToString;
C calls number_to_string.
- Function: make-bytes k1 k2
- Function: make-bytes k1
- Function: bytes k1 ...
-
Top-level variables defined to calls of these procedures will create
static allocations in C.
- Function: substring string start end
- Function: subbytes byte-vector start end
-
Supported in all except WB-C.
- Function: make-vector k fill
- Function: make-vector k
- Function: vector obj1 ...
- Function: make-array prototype bound1 bound2 ...
-
In a define, generates an array of the type as determined by the
variable name and inline declarations or `scm2java.typ'; otherwise
a malloc cast to the type*.
- Function: bytes-length string
- Function: string-length string
- Function: vector-length vector
-
For vectors in C,
sizeof(vector), which is not
necessarily correct.
- Function: vector-set-length! vector k
-
Extends or truncates vector.
- Function: array-ref vector k
- Function: string-ref string k
- Function: byte-ref string k
- Function: vector-ref vector k
-
vector[k]
- Procedure: array-set! array k obj
- Procedure: byte-set! string k1 k2
- Procedure: vector-set! vector k obj
-
array[k] = obj.
Strings are immutable.
- Procedure: current-error-port
- Java
System.out; others stderr
- Procedure: current-output-port
- Java
System.out; others stdout
- Procedure: current-input-port
- Java
System.in; others stdin
- Function: current-time
-
Returns the integer number-of-seconds since Jan 1, 1970.
Functions from Integers as Bits;
SLIB module logical.
- Function: lognot n1
- Function: logand n1 n2
- Function: logtest n1 n2
- Function: logior n1 n2
- Function: logxor n1 n2
-
Translated as the obvious bitwise logical primitives.
- Function: ash n1 n2
- Function: arithmetic-shift n1 n2
-
n2 must be a literal integer.
- Function: logbit? n k
- Function: bit-field n1 n2 n3
-
- Procedure: dprintf "<format>" <expression2> ...
-
Perform stdlib printf
formatted output to the diagnostic
channel,
(current-error-port). Remember to end the
format string with \n for newline.
- Procedure: wdprintf "<format>" <expression2> ...
-
Same as dprintf, but prefixed with WARNING:.
- Procedure: edprintf "<format>" <expression2> ...
-
Same as dprintf, but prefixed
with >>>>ERROR<<<<.
Copyright © 2001, 2002, 2003, 2007, 2009 Aubrey Jaffer
I am a guest and not a member of the MIT Computer Science and Artificial Intelligence Laboratory.
My actions and comments do not reflect in any way on MIT.
|
| | Schlep
|
| agj @ alum.mit.edu
| Go Figure!
|