File: sharp-expr.scm

package info (click to toggle)
gimp 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 222,880 kB
  • sloc: ansic: 870,914; python: 10,965; lisp: 10,857; cpp: 7,355; perl: 4,536; sh: 1,753; xml: 972; yacc: 609; lex: 348; javascript: 150; makefile: 42
file content (85 lines) | stat: -rw-r--r-- 2,581 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
; Tests of sharp expressions in ScriptFu

; This only tests:
;    miscellaneous sharp expressions
; See also:
;   sharp-expr-char.scm
;   sharp-expr-number.scm

; Some "sharp expressions" e.g. #t and #f might not be explicitly tested,
; but tested "driveby" by other tests.

; Terminology:
; The code says "sharp constant expression".
; A "sharp expression" is text in the language that denotes a "sharp constant."
; A constant is an atom of various types: char, byte, number.
; The expression is distinct from the thing it denotes.

; A "sharp expression" is *recognized* by the interpreter.
; But also *printed* by the interpreter REPL.
; Mostly these are tests of recognition.
; The testing framework cannot test the REPL.

; See scheme.c, the token() function, about line 2000
; and the mk_sharp_constant() function, for sharp character constant

; #( token denotes start of a vector

; #! token denotes start of a comment terminated by newline
; aka shebang or hashbang, a notation that OS shells read

; #t denotes true
; #f denotes false

; #odxb<x> denotes a numeric constant in octal, decimal, hex, binary base
; where <x> are digits of that base

; #\<char> denotes a character constant where <char> is one character
; The one character may be multiple bytes in UTF-8,
; but should appear in the display as a single glyph,
; but may appear as a box glyph for unichar chars outside ASCII.

; #\x<x> denotes a character constant where <x> is a sequence of hex digits
; See mk_sharp_const()

; #\space #\newline #\return and #\tab also denote character constants.

; Note: sharp backslash followed by space/blank parses as a token,

; #U+<x> notation for unichar character constants is not in ScriptFu

; Any sharp character followed by characters not described above
; MAY optionally be a sharp expression when a program
; uses the "sharp hook" by defining symbol *sharp-hook* .


; block quote parses
; Seems only testable in REPL?
; Note there is a newline after foo
;(assert '#! foo
;        )
; but is not testable by the framework

; #t denotes truth
(assert #t)

; #t denotes an atom
(assert (atom? #t))

; #t is type boolean
(assert (boolean? #t))
; #t is neither type number or symbol
(assert (not (number? #t)))
(assert (not (symbol? #t)))

; #t denotes constant, and constant means immutable
; You cannot redefine #t
(assert-error `(define #t 1)
              "variable is not a symbol")
; You cannot set #t
(assert-error `(set! #t 1)
              "set!: unbound variable:")
; error-hook omits suffix: #t

; There is no predicate immutable? in Scheme language?