Next: , Previous: Coding With Keywords, Up: Keywords


5.5.8.3 Keyword Read Syntax

Guile, by default, only recognizes a keyword syntax that is compatible with R5RS. A token of the form #:NAME, where NAME has the same syntax as a Scheme symbol (see Symbol Read Syntax), is the external representation of the keyword named NAME. Keyword objects print using this syntax as well, so values containing keyword objects can be read back into Guile. When used in an expression, keywords are self-quoting objects.

If the keyword read option is set to 'prefix, Guile also recognizes the alternative read syntax :NAME. Otherwise, tokens of the form :NAME are read as symbols, as required by R5RS.

To enable and disable the alternative non-R5RS keyword syntax, you use the read-set! procedure documented in User level options interfaces and Reader options.

     (read-set! keywords 'prefix)
     
     #:type
     =>
     #:type
     
     :type
     =>
     #:type
     
     (read-set! keywords #f)
     
     #:type
     =>
     #:type
     
     :type
     -|
     ERROR: In expression :type:
     ERROR: Unbound variable: :type
     ABORT: (unbound-variable)