source: project/chicken/trunk/manual/Non-standard read syntax @ 15896

Last change on this file since 15896 was 15896, checked in by Ivan Raikov, 10 years ago

merged manual from wiki

File size: 3.4 KB
Line 
1[[tags: manual]]
2
3[[toc:]]
4
5== Non-standard read syntax
6
7=== Multiline Block Comment
8
9 #| ... |#
10
11A multiline ''block'' comment. May be nested. Implements [[http://srfi.schemers.org/srfi-30/srfi-30.html|SRFI-30]]
12
13=== Expression Comment
14
15 #;EXPRESSION
16
17Treats {{EXPRESSION}} as a comment.  That is, the comment runs through the whole S-expression, regardless of newlines, which saves you from having to comment out every line, or add a newline in the middle of your parens to make the commenting of the last line work, or other things like that.
18=== External Representation
19
20 #,(CONSTRUCTORNAME DATUM ...)
21
22Allows user-defined extension of external representations. (For more information see the documentation for
23[[http://srfi.schemers.org/srfi-10/srfi-10.html|SRFI-10]])
24
25=== Syntax Expression
26
27 #'EXPRESSION
28
29An abbreviation for {{(syntax EXPRESSION)}}.
30
31=== Location Expression
32
33 #$EXPRESSION
34
35An abbreviation for {{(location EXPRESSION)}}.
36
37=== Keyword
38
39 #:SYMBOL
40 SYMBOL:
41 :SYMBOL
42
43Syntax for keywords. Keywords are symbols that evaluate to themselves, and as such don't have to be quoted.  Either {{SYMBOL:}} or {{:SYMBOL}} is accepted, depending on the setting of the {{keyword-style}} parameter, but never both.  {{#:SYMBOL}} is always accepted.
44
45=== Multiline String Constant
46
47 #<<TAG
48
49Specifies a multiline string constant. Anything up to a line equal to {{TAG}} (or end of file) will be returned as a single string:
50
51 (define msg #<<END
52  "Hello, world!", she said.
53 END
54 )
55
56is equivalent to
57
58 (define msg "\"Hello, world!\", she said.")
59
60=== Multiline String Constant with Embedded Expressions
61
62 #<#TAG
63
64Similar to {{#<<}}, but allows substitution of embedded Scheme expressions prefixed with {{#}} and optionally enclosed in curly brackets. Two consecutive {{#}}s are translated to a single {{#}}:
65
66 (define three 3)
67 (display #<#EOF
68 This is a simple string with an embedded `##' character
69 and substituted expressions: (+ three 99) ==> #(+ three 99)
70 (three is "#{three}")
71 EOF
72 )
73
74prints
75
76 This is a simple string with an embedded `#' character
77 and substituted expressions: (+ three 99) ==> 102
78 (three is "3")
79
80=== Foreign Declare
81
82 #> ... <#
83
84Abbreviation for {{foreign-declare " ... ")}}.
85
86=== Sharp Prefixed Symbol
87
88 #%...
89
90Reads like a normal symbol.
91
92=== Bang
93
94 #!...
95
96Interpretation depends on the directly following characters. Only the following are recognized. Any other case results in a read error.
97
98==== Line Comment
99
100* If followed by whitespace or a slash, then everything up the end of the current line is ignored
101
102==== Eof Object
103
104* If followed by the character sequence {{eof}}, then the (self-evaluating) end-of-file object is returned
105
106==== DSSSL Formal Parameter List Annotation
107
108* If followed by any of the character sequences {{optional}}, {{rest}} or {{key}}, then a symbol with the same name (and prefixed with {{#!}}) is returned
109
110==== Read Mark Invocation
111
112* If a ''read mark'' with the same name as the token is registered, then its procedure is called and the result of the read-mark procedure will be returned
113
114=== Case Sensitive Expression
115
116 #cs...
117
118Read the next expression in case-sensitive mode (regardless of the current global setting).
119
120=== Case Insensitive Expression
121
122 #ci...
123
124Read the next expression in case-insensitive mode (regardless of the current global setting).
125
126=== Conditional Expansion
127
128 #+FEATURE EXPR
129
130Equivalent to
131
132 (cond-expand (FEATURE EXPR) (else))
133
134---
135Previous: [[Extensions to the standard]]
136
137Next: [[Non-standard macros and special forms]]
Note: See TracBrowser for help on using the repository browser.