Skip to content

Conversation

@DerGuteMoritz
Copy link

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 arguments. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant