Next: iklib reader extensions, Previous: iklib reader annotations, Up: iklib reader [Index]
The following syntaxes are available only when the input port mode is
set to vicare.
The vertical bars can be used to specify symbols whose name does not
comply with the R6RS specifications; this syntax is available only
when the port mode is #!vicare. Examples:
(define port (open-string-input-port "|123|")) (set-port-mode! port 'vicare) (define sym (read port)) (symbol? sym) ⇒ #t (symbol->string sym) ⇒ "123"
backslash sequences are allowed in bar symbols:
(define port (open-string-input-port "|123-\x41;\x42;\x43;|")) (set-port-mode! port 'vicare) (define sym (read port)) (symbol? sym) ⇒ #t (symbol->string sym) ⇒ "123-\x41;\x42;\x43;"
notice that the sequence of characters |ciao|hello| is split into
ciao, hello, | and the ending vertical bar would
cause an error if read:
(define port (open-string-input-port "|ciao|hello|")) (set-port-mode! port 'vicare) (read port) ⇒ ciao (read port) ⇒ hello (port-eof? port) ⇒ #f (get-char port) ⇒ #\| (port-eof? port) ⇒ #t
Vicare’s read and write procedures extend the lexical
syntax of Scheme by the ability to read and write gensyms using one of
these three forms.
#{unique-name} constructs, at read time, a gensym whose unique
name is the one specified. If a gensym with the same unique name
already exists in the system’s symbol table, that gensym is returned.
> '#{some-long-name}
#{g0 |some-long-name|}
> (gensym? '#{some-long-unique-name})
#t
> (eq? '#{another-unique-name} '#{another-unique-name})
#t
The two–part #{pretty-name unique-name} gensym syntax is
similar to the syntax shown above with the exception that if a new
gensym is constructed (that is, if the gensym did not already exist in
the symbol table), the pretty name of the constructed gensym is set to
pretty-name.
> '#{foo unique-identifier}
#{foo |unique-identifier|}
> '#{unique-identifier}
#{foo |unique-identifier|}
> '#{bar unique-identifier}
#{foo |unique-identifier|}
Read a keyword object using symbol as symbol. symbol must be a symbol object as defined by R6RS. Keyword objects.
The end–of–file marker, #!eof, is an extension to the R6RS
syntax. The primary utility of the #!eof marker is to stop the
reader (e.g. read and get-datum) from reading the rest of
the file.
(import (vicare)) <some code> (display "goodbye\n") #!eof <some junk>
The #!eof marker also serves as a datum in Vicare, much
like #t and #f, when it is found inside other expressions.
> (eof-object)
#!eof
> (read (open-input-string ""))
#!eof
> (read (open-input-string "#!eof"))
#!eof
> (quote #!eof)
#!eof
> (eof-object? '#!eof)
#t
> #!r6rs #!eof
Unhandled exception
Condition components:
1. &lexical
2. &i/o-read
3. &message: "invalid syntax"
4. &irritants: ("#!eof")
5. &source-position:
port-id: "*stdin*"
...
> #!vicare #!eof
$
Switch between case sensitive and case insensitive identifiers; the
default for R6RS source code is case sensitive. When #ci is
read: the next form read has case insensitive identifiers. When
#cs is read: the next form read has case sensitive identifiers.
#ci(1 2 3) ⇒ (1 2 3) #cs(1 2 3) ⇒ (1 2 3) #ci(1 A 3) ⇒ (1 a 3) #cs(1 A 3) ⇒ (1 A 3) #ci CIAO #cs CIAO ⇒ ciao CIAO #ci CIAO CIAO ⇒ ciao CIAO #ci(A #csB C) ⇒ (a B c) #ci(A #cs B C) ⇒ (a B c)
Next: iklib reader extensions, Previous: iklib reader annotations, Up: iklib reader [Index]