1
Specifications of SigScheme
2
===========================
11
Supports LL64, LLP64, LP64 and ILP64 on both storage-fatty and storage-compact.
13
Addressable memory space
14
~~~~~~~~~~~~~~~~~~~~~~~~
16
Ordinary storage implementation can address any Scheme object scattered on
17
whole memory space. Both storage-fatty and storage-compact have no
18
limitation on any 32 and 64-bit data models. But it may be limited if a
19
storage implementation is designed to do so for some specific advantages,
20
as like GNU Emacs' 28-bit tagged pointer does.
25
Current implementation only supports fixnum, and its range varies by the
26
user-selected underlying storage implementation. The range can be known via
27
R6RS (R5.91RS) compatible `(fixnum-width)`, `(least-fixnum)` and
37
Supported. But the conformance of `eval` procedure is uncertain. See the
38
comments of `scm_p_eval()` and `rec-by-eval` of `test-tail-rec.scm` for further
39
information about `eval`.
44
Limited to nested use due to its setjmp/longjmp implementation. If a
45
continuation that is not an ancestor of current continuation called, all
46
continuation objects lying between the curent and the common ancestor of
47
the destination are invalidated. Calling an invalidated continuation object
53
The hygienic macros are fully supported. But although the macro expansion
54
engine itself works well and can be expected as R5RS-conformant, its
55
integration into SigScheme is not fully validated yet. It is likely having a
56
problem on identifier references.
61
SigScheme supports only the integer part of the numerical tower.
66
SigScheme recognizes only these limited part of numerical forms of "7.1.1
67
Lexical structure" section of R5RS. Other valid R5RS forms for numbers produce
70
----------------------------------------------------------------
71
<number> --> <num 2>| <num 8>
74
<num R> --> <prefix R> <complex R>
75
<complex R> --> <real R>
76
<real R> --> <sign> <ureal R>
77
<ureal R> --> <uinteger R>
78
<uinteger R> --> <digit R>+ #* ;; '#' must not occur
79
<prefix R> --> <radix R>
81
<sign> --> <empty> | + | -
84
<radix 10> --> <empty> | #d
87
<digit 8> --> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
88
<digit 10> --> <digit>
89
<digit 16> --> <digit 10> | a | b | c | d | e | f
90
<digit> --> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
91
----------------------------------------------------------------
93
SigScheme accepts only lower case alphabets as radices as follows. But
94
hexadecimal digits can be written as either lower or upper.
96
----------------------------------------------------------------
102
----------------------------------------------------------------
104
SigScheme uses a fixed-size buffer for number literals parsing. Due to the
105
implementation, it can accept only one optional '0' prefix for maximum-length
106
binary number literals. Two or more '0' prefixes causes an error as follows.
108
----------------------------------------------------------------
109
;; storage-compact on ILP32 env
111
(greatest-fixnum) ==> 2147483647
112
#b11111111000000001111111100000000 ==> 4278255360
113
#b011111111000000001111111100000000 ==> 4278255360
114
#b0011111111000000001111111100000000 ==> error
115
#b00011111111000000001111111100000000 ==> error
116
----------------------------------------------------------------
121
The procedures '-' and '/' support following optional form.
123
----------------------------------------------------------------
124
6.2.5 Numerical operations
126
optional procedure: - z1 z2 ...
127
optional procedure: / z1 z2 ...
128
----------------------------------------------------------------
134
All character category-sensitive procedures and predicates (such as
135
char-upcase) work correctly only in ASCII range. i.e. Neither Unicode
136
processing specified in SRFI-75 nor other non-Unicode multibyte character
137
processing are supported in such procedures/predicates.
139
Case-insensitive character comparison
140
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
SigScheme's case-insensitive comparison conforms to the foldcase'ed
143
comparison described in SRFI-75 and SRFI-13, although R5RS does not specify
144
comparison between alphabetic and non-alphabetic char.
146
See the description in operations.c for further details.
148
Case-sensitive identifiers
149
~~~~~~~~~~~~~~~~~~~~~~~~~~
151
SigScheme does distinguish letter case in indentifiers. Although case
152
insensitivity is required in R5RS as follows, it is hard to accept for the
155
----------------------------------------------------------------
156
2. Lexical conventions
158
Upper and lower case forms of a letter are never distinguished except
159
within character and string constants. For example, `Foo' is the same
160
identifier as `FOO', and #x1AB is the same number as #X1ab.
161
----------------------------------------------------------------
166
SigScheme treats string literals as constant as specified in R5RS.
169
================================================================
170
sscm> (string-set! "foo" 0 #\F)
171
Error: in string-set!: attempted to modify immutable string: "foo"
173
sscm> (string-set! (string-copy "foo") 0 #\F)
175
================================================================
180
SigScheme inhibits modification of constant list object by default as
181
specified in R5RS, if the storage implementation suports it. storage-fatty
182
supports it, but storage-compact does not due to no bit space for pair
185
The behavior can be changed by `SCM_CONST_LIST_LITERAL`.
187
----------------------------------------------------------------
188
4.1.2 Literal expressions
190
`(quote <datum>)' may be abbreviated as '<datum>. The two notations
191
are equivalent in all respects.
194
'#(a b c) ==> #(a b c)
197
'(quote a) ==> (quote a)
200
As noted in section 3.4 Storage model, it is an error to alter a
201
constant (i.e. the value of a literal expression) using a mutation
202
procedure like `set-car!' or `string-set!'.
204
6.3.2 Pairs and lists
206
procedure: set-car! pair obj
208
Stores obj in the car field of pair. The value returned by `set-car!'
211
(define (g) '(constant-list))
212
(set-car! (g) 3) ==> error
213
----------------------------------------------------------------
218
SigScheme inhibits modification of constant vector object by default as
219
specified in R5RS, if the storage implementation suports it. storage-fatty
220
supports it, but storage-compact is not yet.
222
The behavior can be changed by `SCM_CONST_VECTOR_LITERAL`.
224
----------------------------------------------------------------
227
procedure: vector-set! vector k obj
229
(vector-set! '#(0 1 2) 1 "doe")
230
==> error ; constant vector
231
----------------------------------------------------------------
236
SigScheme allows quote-less null list by default for convenience and
237
performance. But it can be error as specified in R5RS, when `SCM_STRICT_R5RS`
240
.SCM_STRICT_R5RS disabled
241
================================================================
244
================================================================
246
.SCM_STRICT_R5RS enabled
247
================================================================
249
Error: eval: () is not a valid R5RS form. use '() instead
250
================================================================
252
Quote-less vector literal
253
~~~~~~~~~~~~~~~~~~~~~~~~~
255
Sigscheme inhibits quote-less vector literal by default, as specified in
258
The behavior can be changed by `SCM_STRICT_VECTOR_FORM`.
260
----------------------------------------------------------------
263
Vectors are written using the notation #(obj ...). For example, a vector
264
of length 3 containing the number zero in element 0, the list `(2 2 2 2)'
265
in element 1, and the string `"Anna"' in element 2 can be written as
268
#(0 (2 2 2 2) "Anna")
270
Note that this is the external representation of a vector, not an
271
expression evaluating to a vector. Like list constants, vector constants
274
'#(0 (2 2 2 2) "Anna")
275
==> #(0 (2 2 2 2) "Anna")
276
----------------------------------------------------------------
279
================================================================
281
Error: eval: #() is not a valid R5RS form. use '#() instead
284
================================================================
286
Environment specifiers
287
~~~~~~~~~~~~~~~~~~~~~~
289
`(null-environment)` and `(scheme-report-environment)` does not return correct
290
environemnt specified in R5RS. Current implementation returns same object
291
of `(interaction-environment)`.
296
SigScheme strictly conforms to the 'internal definitions' defined in R5RS
297
(cited below) if `SCM_STRICT_DEFINE_PLACEMENT` is enabled (default). It can be
298
disabled to get the syntax loosen, shrink the footprint and reduce runtime
301
----------------------------------------------------------------
302
5.2.2 Internal definitions
304
Definitions may occur at the beginning of a <body> (that is, the body of a
305
lambda, let, let*, letrec, let-syntax, or letrec-syntax expression or that of
306
a definition of an appropriate form). Such definitions are known as internal
307
definitions as opposed to the top level definitions described above.
308
----------------------------------------------------------------
310
Superfluous arguments
311
~~~~~~~~~~~~~~~~~~~~~
313
Superfluous or dotted arguments are strictly rejected as an error if
314
`SCM_STRICT_ARGCHECK` is enabled. Otherwise ignored. Resource-sensitive
315
apprication could disable it.
317
.SCM_STRICT_ARGCHECK enabled
318
================================================================
319
sscm> (car '(1 2) 3 4)
320
Error: in (function call): superfluous argument(s): (3 4)
321
sscm> (symbol? 'foo . #t)
322
Error: in (function call): improper argument list terminator: #t
324
Error: in (reduction): improper argument list terminator: 5
325
================================================================
327
.SCM_STRICT_ARGCHECK disabled
328
================================================================
329
sscm> (car '(1 2) 3 4)
331
sscm> (symbol? 'foo . #t)
335
================================================================
337
Syntaxes/procedures not implemented
338
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
340
Following R5RS syntaxes and procedures are not implemented (yet).
345
- *procedure:* complex? obj
346
- *procedure:* real? obj
347
- *procedure:* rational? obj
348
- *procedure:* exact? z
349
- *procedure:* inexact? z
350
- *library procedure:* gcd n1 ...
351
- *library procedure:* lcm n1 ...
352
- *procedure:* numerator q
353
- *procedure:* denominator q
354
- *procedure:* floor x
355
- *procedure:* ceiling x
356
- *procedure:* truncate x
357
- *procedure:* round x
358
- *library procedure:* rationalize x y
364
- *procedure:* asin z
365
- *procedure:* acos z
366
- *procedure:* atan z
367
- *procedure:* atan y x
368
- *procedure:* sqrt z
369
- *procedure:* expt z1 z2
370
- *procedure:* make-rectangular x1 x2
371
- *procedure:* make-polar x3 x4
372
- *procedure:* real-part z
373
- *procedure:* imag-part z
374
- *procedure:* magnitude z
375
- *procedure:* angle z
376
- *procedure:* exact->inexact z
377
- *procedure:* inexact->exact z
382
- *library syntax:* delay <expression>
383
- *library procedure:* force promise
388
- *optional procedure:* transcript-on filename
389
- *optional procedure:* transcript-off
398
Although a C implementation `module-srfi1.c` is existing, it is still broken
399
and should not use for production codes. To get SRFI-1 working with SigScheme,
400
use SLIB version of the library (will be made available after some
404
SRFI-22 Running Scheme Scripts on Unix
405
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
407
SigScheme only supports the prelude line interpretation. All options written in
408
the line are applied as same as commandline invocation of sscm. But the `main`
409
procedure invocation is not supported (yet).
411
.Prelude line is interpreted as follows
412
================================================================
413
#! /usr/bin/env sscm -C UTF-8
416
==> Character encoding for the file is changed to UTF-8 temporarily.
417
================================================================
420
SRFI-23 Error Reporting Mechanism
421
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
423
If srfi-34 is provided, the `error` procedure throws a SigScheme-specific error
424
object in cooperate with "SRFI-34 Exception Handling for Programs". Otherwise
425
it simply calls scm_fatal_error(). Since the error objects are represented as a
426
list, be careful on catching an exception based on its type. If you want to
427
distinguish the error objects from ordinary lists, use SigScheme-specific
428
`%%error-object?` predicate.
430
.Error objects are also caught as a list
431
================================================================
432
sscm> (guard (obj ((pair? obj) obj)) (error "reason" 1 2 3))
433
#<error "reason" 1 2 3>
434
================================================================
437
.Error object internal
438
================================================================
439
sscm> (define err (guard (err (#t err)) (error "reason" 1 2 3)))
442
#<error "reason" 1 2 3>
446
(#<undef> . #<undef>)
447
sscm> (%%error-object? err)
449
================================================================
451
SRFI-28 Basic Format Strings
452
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454
SigScheme fully supports SRFI-28. A directive-less tilde at end of a format
455
string causes an error as same as the reference implementation of SRFI-28.
458
================================================================
459
(format "~") ==> error
460
(format "a~") ==> error
461
================================================================
463
SRFI-38 External Representation for Data with Shared Structure
464
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
466
Only `write-with-shared-structure` is implemented and
467
`read-with-shared-structure` is not. The optional alias `write/ss` described in
468
SRFI-38 is also defined. The optional `optarg` argument is simply ignored.
470
The shared index starts with #1 (not #0).
472
.Shared index starts with #1
473
================================================================
474
sscm> (define lst (list 'a 'b))
476
sscm> (set-cdr! lst lst)
480
================================================================
482
SRFI-48 Intermediate Format Strings
483
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
485
SigScheme fully supports SRFI-48.
487
The 'd' part of '~w,dF' directive is acceptable, but completely ignored on
488
output format. Since SigScheme only supports integer currently, number is
489
always formatted as integer even if the 'd' part is specified.
492
================================================================
493
(format "~3F" 3) ==> " 3"
494
(format "~3,2F" 3) ==> "3.00"
495
================================================================
498
================================================================
499
(format "~3F" 3) ==> " 3"
500
(format "~3,2F" 3) ==> " 3"
501
================================================================
503
Although the reference implementation of SRFI-48 allows directive-less tilde at
504
end of a format string, SigScheme rejects it as an error since it decreases
505
user-code portability, and is confusable due to that the behavior is different
506
to the reference implementation of SRFI-28.
508
.Reference implementation of SRFI-48
509
================================================================
511
(format "a~") ==> "a~"
512
================================================================
515
================================================================
516
(format "~") ==> error
517
(format "a~") ==> error
518
================================================================
521
SRFI-60 Integer as Bits
522
~~~~~~~~~~~~~~~~~~~~~~~
524
Only following procedures are implemented.
527
* *procedure:* logand n1 ...
528
* *procedure:* bitwise-and n1 ...
529
* *procedure:* logior n1 ...
530
* *procedure:* bitwise-ior n1 ...
531
* *procedure:* logxor n1 ...
532
* *procedure:* bitwise-xor n1 ...
533
* *procedure:* lognot n
534
* *procedure:* bitwise-not n
535
* *procedure:* bitwise-if mask n0 n1
536
* *procedure:* bitwise-merge mask n0 n1
537
* *procedure:* logtest j k
538
* *procedure:* any-bits-set? j k
540
And the others listed below are not.
543
* *procedure:* logcount n
544
* *procedure:* bit-count n
545
* *procedure:* integer-length n
546
* *procedure:* log2-binary-factors n
547
* *procedure:* first-set-bit n
550
* *procedure:* logbit? index n
551
* *procedure:* bit-set? index n
552
* *procedure:* copy-bit index from bit
555
* *procedure:* bit-field n start end
556
* *procedure:* copy-bit-field to from start end
557
* *procedure:* ash n count
558
* *procedure:* arithmetic-shift n count
559
* *procedure:* rotate-bit-field n count start end
560
* *procedure:* reverse-bit-field n start end
563
* *procedure:* integer->list k len
564
* *procedure:* integer->list k
565
* *procedure:* list->integer list
566
* *procedure:* booleans->integer bool1 ...
568
SRFI-75 R6RS Unicode data
569
~~~~~~~~~~~~~~~~~~~~~~~~~
571
SRFI-75 is partially implemented. But since SRFI-75 had already been obsoleted,
572
it is not validated deeply. It will be replaced with stable R6RS implementation
573
once the specifications have been stabilized
575
Current SRFI-75 status
576
^^^^^^^^^^^^^^^^^^^^^^
578
- Supports Unicode character literals such as #\λ
579
- Supports #xXX, #\uXXXX and #\UXXXXXXXX literals
580
- Supports Unicode identifiers (lacks character category validation)
581
- Supports all named chars such as #\backspace, #\esc, and #\nul
582
- Quoted-symbol by vertical bar (such as '|-symbol|) is not supported
587
- Remove #\uXXXX and #\UXXXXXXXX literals
588
- Support variable-length #\xXX literal
589
- Support character category validation for identifiers
590
- Disable #\newline on R6RS-compatible mode
591
- Confirm symbol escape syntax (not defined in R6RS yet)
597
FIXME: describe them.
601
- let and let* bindings