jcoglan/heist — pull request #2 by DerGuteMoritz (2012-02-18 15:53:12+00:00)
Title: Keywords

This branch implements the keyword datatype. Keywords live in the same namespace as regular symbols but unlike them they are self-quoting. They end in `:`, e.g. `foo:` (some Scheme implementations also allow prefix notation as in `#:foo`; this branch only implements suffix notation though). They can be used to implement keyword function. Silly example ahead:

(define (greet name . args)
(let-keywords args ((separator ", ") enthusiastic)
(display "Hello")
(display separator)
(display name)
(display (if enthusiastic "!" "."))
(newline)))

(greet "James")
Hello, James.
(greet "James" enthusiastic: #t)
Hello, James!
(greet "James" enthusiastic: #t separator: " ... ")
Hello ... James!